-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTL_maps.cpp
More file actions
44 lines (38 loc) · 923 Bytes
/
Copy pathSTL_maps.cpp
File metadata and controls
44 lines (38 loc) · 923 Bytes
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
42
43
#include <cstdio>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main() {
int elem_num;
cin>>elem_num;
std::map<string, int> m;
for(int i=0;i<elem_num;i++){
int query;
string name;
int num;
std::cin>>query;
std::cin>>name;
if(query==1){
int new_num;
std::cin>>num;
if(m.find(name) == m.end())
m.insert(make_pair(name,num));
else{
new_num = m.find(name)->second + num;
m.erase(name);
m.insert({name,new_num});
}
}
if(query==2){
m.erase(name);
}
if(query==3){
if( m.find(name) != m.end())
std::cout << m.find(name)->second<< "\n";
else
std::cout << "0\n";
}
}
return 0;
}