ash_sinha

Untitled

Sep 18th, 2022
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. using namespace __gnu_pbds;
  4. using namespace std;
  5.  
  6. #define ff first
  7. #define ss second
  8. #define int long long
  9. #define pb push_back
  10. #define mp make_pair
  11. #define pii pair<int,int>
  12. #define vi vector<int>
  13. #define mii map<int,int>
  14. #define pqb priority_queue<int>
  15. #define pqs priority_queue<int,vi,greater<int> >
  16. #define setbits(x) __builtin_popcountll(x)
  17. #define zrobits(x) __builtin_ctzll(x)
  18. #define mod 1000000007
  19. #define inf 1e18
  20. #define ps(x,y) fixed<<setprecision(y)<<x
  21. #define mk(arr,n,type) type *arr=new type[n];
  22. #define w(x) int x; cin>>x; while(x--)
  23. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  24. #define fastio ios_base::sync_with_stdio(0); cin.tie(0);
  25.  
  26. bool cmp1(pair<pair<string,int>,int>&a,pair<pair<string,int>,int>&b)
  27. {
  28. if(a.ff.ff==b.ff.ff) return a.ss<b.ss;
  29. return a.ff.ff<b.ff.ff;
  30. }
  31. bool cmp2(pair<pair<string,int>,int>&a,pair<pair<string,int>,int>&b)
  32. {
  33. if(a.ff.ss==b.ff.ss) return a.ss<b.ss;
  34. return a.ff.ss<b.ff.ss;
  35. }
  36.  
  37. int32_t main()
  38. {
  39. int tt;cin>>tt;
  40. for(int t=1;t<=tt;t++)
  41. {
  42. int n;
  43. cin>>n;
  44. vector<pair<pair<string,int>,int>> a(n),b(n);
  45. for(int i=0;i<n;i++)
  46. {
  47. int d,u;string s;
  48. cin>>s>>d>>u;
  49. a[i]={{s,d},u};
  50. b[i]={{s,d},u};
  51. }
  52. sort(a.begin(),a.end(),cmp1);
  53. sort(b.begin(),b.end(),cmp2);
  54. int ans=0;
  55. for(int i=0;i<n;i++) if(a[i]==b[i]) ans++;
  56. cout<<"Case #"<<t<<": "<<ans<<"\n";
  57.  
  58. }
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment