全WA了求助大佬
查看原帖
全WA了求助大佬
1419017
z1443888087楼主2025/1/11 21:16
#include<iostream>
using namespace std;
#include<map>
int main(){
	map<string,int>m;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int p;
		string s;int ss;
		cin>>p;
		if(p==1){
			cin>>s;
			cin>>ss;
			m[s]=ss;
			cout<<"OK"<<endl;
		}
		else if(p==2){
			cin>>s;
			if(m.count(s)){
				auto it=m.find(s);
				cout<<it->second<<endl;
				continue;
			}
			cout<<"No found"<<endl;
		}
		else if(p==3){
			cin>>s;
			if(m.count(s)){
				m.erase(s);
				cout<<"Deleted successfully"<<endl;
				continue;
			}
			cout<<"No found"<<endl;
		}
		else if(p==4){
			if(m.empty())cout<<"0"<<endl;
			else {
				int k=m.size();
				cout<<k<<endl;
			}
		}
	}
}
2025/1/11 21:16
加载中...