为什么这样写会全WA呢?
查看原帖
为什么这样写会全WA呢?
422387
VIOLET__FOREVER楼主2022/4/23 10:35
#include<bits/stdc++.h>
using namespace std;
int n,num,m,ans;
string name;
map <string, int> s;
int main(){
	cin>>n;
	while(n--){
		cin>>num;
		if(num==1){
			cin>>name>>m;
			if(!s[name]) ans++;
			s[name]=m;
			cout<<"OK"<<endl;
		}
		else if(num==2){
			cin>>name;
			if(s[name]) cout<< s[name] <<endl;
			else cout<<"Not found"<<endl;
		}
		else if(num==3){
			cin>>name;
			if(s[name]){
				ans--;
				s[name]=0;
				cout<<"Deleted successfully"<<endl;
			}
			else cout<<"Not found";
		}
		else cout<<ans<<endl;
	}
	return 0;
}
2022/4/23 10:35
加载中...