fork download
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int V[1000];
  5. // Declaring functions
  6. void aggiungi(long long int id,int V[]) {
  7. V[id]=V[id]+1;
  8.  
  9. }
  10.  
  11. void togli(long long int id,int V[]) {
  12. V[id]=V[id]-1;
  13.  
  14. }
  15.  
  16. int conta(long long int id,int V[]) {
  17. return V[id];
  18.  
  19. }
  20.  
  21. int main() {
  22. ios::sync_with_stdio(false);
  23.  
  24. // Uncomment the following lines if you want to read/write from files
  25. // ifstream cin("input.txt");
  26. // ofstream cout("output.txt");
  27.  
  28. int Q;
  29. cin >> Q;
  30.  
  31. for(int i = 0; i < Q; i++){
  32. char t;
  33. long long int id;
  34. cin >> t >> id;
  35.  
  36. if(t == 'a') {
  37. aggiungi(id,V);
  38. } else if (t == 't') {
  39. togli(id,V);
  40. } else if (t == 'c') {
  41. cout << conta(id,V) << '\n';
  42. }
  43. }
  44.  
  45.  
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5280KB
stdin
11
a 11
a 11
a 10
a 10
c 13
c 10
a 10
a 10
t 11
c 11
c 10
stdout
0
2
1
4