1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include <bits/stdc++.h> using namespace std; unordered_map<string, int> mp;
int main() { int n, opt, score; string name; cin >> n; while (n--) { cin >> opt; if (opt == 1) { cin >> name >> score; mp[name] = score; cout << "OK" << endl; } else if (opt == 2) { cin >> name; if (!mp.count(name)) cout << "Not found" << endl; else cout << mp[name] << endl; } else if (opt == 3) { cin >> name; if (!mp.count(name)) cout << "Not found" << endl; else mp.erase(name), cout << "Deleted successfully" << endl; } else { cout << mp.size() << endl; } } return 0; }
|