全 WA 了,樣例過了,很奇怪
查看原帖
全 WA 了,樣例過了,很奇怪
408019
ShanCreeperProEnder楼主2022/5/28 21:24

用的 map,自己隨便試的數據也都可以,爲啥全 WA 了

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fore(i,x,n) for(int i=x;i<=n;i++)
const int MAXX=10005;
const int mod=1;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void writesp(int x){
    write(x);
    putchar(' ');
}
inline void writeln(int x){
    write(x);
    putchar('\n');
}
map<string,int> ds;
int n;
string name;
int opt,num;
signed main(){
#ifdef LOCAL
    freopen("debug_data.in","r",stdin);
    freopen("debug_data.out","w",stdout);
#endif
    n=read();
    while(n--){
        opt=read();
        if(opt==1){
            name=getchar();
            num=read();
            ds[name]=num;
            puts("OK");
        }
        else if(opt==2){
            name=getchar();
            if(ds.count(name)){
                writeln(ds[name]);
            }
            else puts("Not found");
        }
        else if(opt==3){
            name=getchar();
            if(ds.count(name)){
                ds.erase(name);
                puts("Deleted successfully");
            }
            else puts("Not found");
        }
        else writeln(ds.size());
    }
}
2022/5/28 21:24
加载中...