全WA为啥
查看原帖
全WA为啥
632062
NTFS楼主2023/3/12 01:24

样例过了但是全红

#include <iostream>
#include <map>
#include <string.h>
using namespace std;
map<string,int> mp;
int type,n;
string s;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>type;
		if(type==0)return 0;
		else if(type==1)
		{
			cin>>s;
			int x;
			cin>>x;
			mp[s]=x;
			cout<<"OK\n";
		}
		else if(type==2){
			cin>>s;
			if(!mp.count(s)){
				cout<<"Not found\n";
			}else{
				cout<<mp[s]<<endl;
			}
		}else if(type==3){
			cin>>s;
			if(mp.count(s)){
				mp.erase(s);
				cout<<"Deleted successfully"<<endl;
			}
			else{
				cout<<"Not found\n"<<endl;
			}
		}else if(type==4)cout<<mp.size()<<endl;
	}
}
2023/3/12 01:24
加载中...