-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaps.cpp
More file actions
46 lines (44 loc) · 1.02 KB
/
Copy pathmaps.cpp
File metadata and controls
46 lines (44 loc) · 1.02 KB
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
44
45
46
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
std::map<std::string, int>m;
int Q;
std::cin>>Q;
for(int i=0; i<Q; i++){
int ch,y;
std::string x;
std::cin>>ch;
if(ch==1){
cin>>x>>y;
std::map<std::string, int>::iterator it = m.find(x);
if(it==m.end()){
m.insert(make_pair(x,y));
}
else{
it->second+=y;
}
}
else if(ch==2){
cin>>x;
m.erase(x);
}
else if(ch==3){
cin>>x;
std::map<std::string,int>::iterator it = m.find(x);
if(it == m.end()){
std::cout<<"0"<<std::endl;
}
else{
std::cout<<it->second<<std::endl;
}
}
}
return 0;
}