Advertisement
esraa_syam

annoying problemmmmm

Mar 30th, 2023
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.16 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define nl "\n"
  3. #define fi first
  4. #define se second
  5. #define pi 3.14159
  6. #define ll long long
  7. #define odd(a)  (a&1)
  8. #define even(a)  !(a&1)
  9. #define Mod 1'000'000'007
  10. #define INF 2'000'000'000
  11. #define sz(x) int(x.size())
  12. #define charToInt(s) (s - '0')
  13. #define ull unsigned long long
  14. #define number_line iota(all(vec) , 1)
  15. #define all(s) s.begin(), s.end()
  16. #define rall(v) v.rbegin() , v.rend()
  17. #define fixed(n) fixed << setprecision(n)
  18. #define Num_of_Digits(n) ((int)log10(n) + 1)
  19. #define to_decimal(bin) stoll(bin, nullptr, 2)
  20. #define Ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  21. #define Floor(n, m) (((n) / (m)) - ((n) % (m) ? 0 : 1))
  22. #define Upper(s) transform(all(s), s.begin(), ::toupper);
  23. #define Lower(s) transform(all(s), s.begin(), ::tolower);
  24. #define cout_map(mp) for(auto& [f, s] : mp) cout << f << "  " << s << "\n";
  25. //  ----- bits-------
  26. #define pcnt(n) __builtin_popcount(n)  
  27. #define pcntll(n) __builtin_popcountll(n)
  28. #define clz(n) __builtin_clz(n)    // <---100
  29. #define clzll(n) __builtin_clzll(n)
  30. #define ctz(n) __builtin_ctz(n)  // 0001---->
  31. #define ctzll(n) __builtin_ctzll(n)
  32.  
  33. using namespace std;
  34.  
  35. template < typename T = int > istream& operator >> (istream &in, vector < T > & v){
  36.     for(auto & x : v) in >> x;
  37.     return in;
  38. }
  39.  
  40. template < typename T = int > ostream& operator << (ostream &out, const vector < T > & v){
  41.     for(const T & x : v) out << x << nl;
  42.     return out;
  43. }
  44.  
  45. void esraa()
  46. {
  47.     //freopen("shuffle.in", "r", stdin), freopen("shuffle.out", "w", stdout);
  48.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  49. #ifndef ONLINE_JUDGE
  50.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  51. #endif
  52. }
  53. void solve(){
  54.     unordered_map < string , int > mp;
  55.     mp.insert({"Friday" , 0});
  56.     mp.insert({"Thursday" , 0});
  57.     mp.insert({"Wednesday" , 0});
  58.     mp.insert({"Tuesday" , 0});
  59.     mp.insert({"Monday" , 0});
  60.     mp.insert({"Sunday" , 0});
  61.     mp.insert({"Saturday" , 0});
  62.     for(int i = 0 ; i < 7 ; i++){
  63.         string s , t;
  64.         cin >> s >> t;
  65.         int h = (charToInt(t[0]) * 10 + charToInt(t[1])) * 3600;
  66.         int m = (charToInt(t[3]) * 10 + charToInt(t[4])) * 60;
  67.         int sec = charToInt(t[6]) * 10 + charToInt(t[7]);
  68.         int total = h + m + sec;
  69.         mp[s] = total;
  70.     }
  71.     int n;
  72.     cin >> n;
  73.     while(n--){
  74.         string s , t;
  75.         cin >> s >> t;
  76.         int h = (charToInt(t[0]) * 10 + charToInt(t[1])) * 3600;
  77.         int m = (charToInt(t[3]) * 10 + charToInt(t[4])) * 60;
  78.         int sec = charToInt(t[6]) * 10 + charToInt(t[7]);
  79.         int time = h + m + sec;
  80.         int time2 = mp[s];
  81.         int t2;
  82.         auto it = mp.find(s);
  83.         it++;
  84.         if(it != mp.end()){
  85.             t2 = it->second;
  86.            // cout << it -> first << nl;
  87.         }else t2 = mp.begin()->second;
  88.        // cout << time << " " << time2 << " " << t2 << nl;
  89.         if(time2 > time) cout << time2 - time << nl;
  90.         else cout << 86400 + abs(time - t2) << nl;    
  91.     }
  92.  
  93. }
  94. int main()
  95. {
  96.     esraa();
  97.     int t = 1;
  98.     //cin >> t;
  99.     //cin.ignore();
  100.     while(t--)
  101.       solve();
  102.     return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement