fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3.  
  4. using namespace std;
  5. using namespace __gnu_pbds;
  6.  
  7. typedef tree<
  8. tuple<int, int, int>,
  9. null_type,
  10. less<tuple<int, int, int>>,
  11. rb_tree_tag,
  12. tree_order_statistics_node_update> ordered_set;
  13.  
  14.  
  15. int main()
  16. {
  17. int n;
  18. scanf("%d", &n);
  19. ordered_set me[2];
  20. for(int i = 0; i < n; i++)
  21. {
  22. int a, t, x;
  23. scanf("%d%d%d", &a, &t, &x);
  24. if(a == 1)
  25. me[0].insert(make_tuple(x, t, i));
  26. else if(a == 2)
  27. me[1].insert(make_tuple(x, t, i));
  28. else
  29. cout << me[0].order_of_key(make_tuple(x, t + 1, 0)) - me[0].order_of_key(make_tuple(x, 0, 0)) -
  30. (me[1].order_of_key(make_tuple(x, t + 1, 0)) - me[1].order_of_key(make_tuple(x, 0, 0)))<< "\n";
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
Standard output is empty