样例过了,但是全WA,求大佬调代码
查看原帖
样例过了,但是全WA,求大佬调代码
1047537
wuzhuoran楼主2023/12/24 19:49
#include<iostream>
#include <map>
using namespace std;

    map<string,int> m;
	int n;


int main(){

	cin>>n;
	for(int i=0; i<n; i++){
		int op;
		string name;
		cin>>op;
		if(op==1){
			cin>>name;
			int s;
			cin>>s;
			m[name]=s;
			cout<<"OK"<<endl;
		}
		else if(op==2){
			cin>>name;
			if(m.count(name)){
				cout<<m[name];
			}
			else{
				cout<<"Not found"<<endl;
			}
		}
		else if(op==3){
			cin>>name;
			if(m.count(name)){
				m.erase(name);
				cout<<"Deleted successfully"<<endl;
			}
			else{
				cout<<"Not found"<<endl;
			}
		}
		else{
			cout<<m.size()<<endl;
		}
	}
    return 0;
}

2023/12/24 19:49
加载中...