Advertisement
Zeinab_Hamdy

Untitled

Jun 10th, 2022
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define ull unsigned long long
  4. #define newl cout<<"\n";
  5. #define space cout<<" ";
  6. #define sz(x) x.size()
  7. #define NumOfDigit(w) log10(w) + 1
  8. #define MOD 1'000'000'007
  9. #define inf 2'000'000'000
  10. #define PI 3.141592654
  11. #define modulo(a, b, mod) ((((a) % (mod)) + ((b) % (mod))) % (mod))
  12. #define ceil(w, m) (((w) / (m)) + ((w) % (m) ? 1 : 0))
  13. #define all(v) v.begin(), v.end()
  14. #define rall(v) v.rbegin(), v.rend()
  15. #define cin(v) for (auto&i:v) cin >> i;
  16. #define cout(v) for (auto&i:v) cout << i << " ";
  17. #define fixed(n) fixed << setprecision(n)
  18. using namespace std;  
  19. void zainab_hamdy(){
  20.   ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  21. // freopen("schedule.in" , "r" ,stdin);
  22.  #ifndef ONLINE_JUDGE  
  23.      freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  24.  #endif  
  25. }
  26. bool comp(pair<ll,ll> a, pair<ll ,ll> b){
  27.   return a.second < b.second;
  28. }
  29. int main(){
  30. zainab_hamdy();
  31. int t; cin>>t;
  32. while(t--){
  33.   int n; cin>>n;
  34.  vector<pair<ll,ll>> am;
  35.   vector<pair<ll,ll>>  pm;
  36.    int idx=0;
  37.    while(n--){
  38.     int num,p1,p2,p3; string time;
  39.     char c;
  40.     cin >> num >> p1 >> c >> p2 >> c >> p3 >> time;
  41.     if(time=="AM")
  42.          am.emplace_back(num,p3 + p2 * 60 + p1 * 60 * 60);
  43.     else
  44.          pm.emplace_back(num, p3 + p2 * 60 + p1 * 60 * 60);
  45.    
  46.    }
  47. sort(all(am),comp);
  48. sort(all(pm),comp);
  49.  
  50. for(auto & i: am)   cout << i.first << " " ;
  51. for(auto & i: pm)   cout << i.first << " " ;
  52.  
  53. newl
  54.  }
  55.  return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement