求助,全WA了,过了样例
查看原帖
求助,全WA了,过了样例
403452
Dream_Dream楼主2021/11/10 21:44
#include <bits/stdc++.h>
using namespace std;
map<string, int> a;
int n;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int op;
		string name;
		cin >> op;
		if (op != 4) cin >> name;
		if (op == 1) {
			int score;
			cin >> score;
			a[name] = score;
			cout << "OK" << endl; 
		}
		if (op == 2) {
			if (a.count(name)) cout << a[name] << endl;
			else cout << "Not found" << endl;
		}
		if (op == 3) {
			if (a.count(name)) a.erase(name);
			cout << "Deleted successfully" << endl;
		}
		if (op == 4) {
			cout << a.size() << endl;
		}
	}
	return 0;
}
2021/11/10 21:44
加载中...