fork(15) download
  1. #include <ext/pb_ds/assoc_container.hpp>
  2. #include <ext/pb_ds/tree_policy.hpp>
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace __gnu_pbds;
  6. using namespace std;
  7.  
  8. typedef
  9. tree<
  10. pair<int,int>,
  11. null_type,
  12. less<pair<int,int>>,
  13. rb_tree_tag,
  14. tree_order_statistics_node_update>
  15. ordered_set;
  16.  
  17. main()
  18. {
  19. ios::sync_with_stdio(0);
  20. cin.tie(0);
  21. int n;
  22. int sz=0;
  23. cin>>n;
  24. vector<int> ans(n,0);
  25.  
  26. ordered_set t;
  27. int x,y;
  28. for(int i=0;i<n;i++)
  29. {
  30. cin>>x>>y;
  31. ans[t.order_of_key({x,++sz})]++;
  32. t.insert({x,sz});
  33. }
  34.  
  35. for(int i=0;i<n;i++)
  36. cout<<ans[i]<<'\n';
  37. }
Success #stdin #stdout 0s 3440KB
stdin
5
1 1
5 1
7 1
3 3
5 5
stdout
1
2
1
1
0