0分求条(玄关)
查看原帖
0分求条(玄关)
894765
Lantern_LZY楼主2024/11/2 10:23

#include <bits/stdc++.h>

using namespace std;

int n,op,score;
string name;
map<string,int> mp;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>op;
		if(op==1){
			cin>>name>>score;
			mp.insert(pair<string,int>(name,score));
			cout<<"OK"<<endl;
		}
		if(op==2){
			cin>>name;
			if(mp.count(name)){
				cout<<mp[name]<<endl;
			}
			else{
				cout<<"Not found"<<endl;
			}
		}
		if(op==3){
			cin>>name;
			if(mp.count(name)){
				mp.erase(name);
				cout<<"Deleted successfully"<<endl;
			}
			else{
				cout<<"Not found"<<endl;
			}
		}
		if(op==4){
			cout<<mp.size()<<endl;
		}
	}
}
2024/11/2 10:23
加载中...