Advertisement
SorahISA

2019 NHSPC north1 pE

Nov 13th, 2019
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #pragma GCC optimized("Ofast, unroll-loops")
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. #define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
  7. #define X first
  8. #define Y second
  9. #define Push push_back
  10. #define ALL(x) x.begin(), x.end()
  11.  
  12. using lli = long long;
  13. using pll = pair<lli, lli>;
  14. using Double = long double;
  15. template<typename T>
  16. using Vector = vector<vector<T>>;
  17. template<typename T>
  18. using prior = priority_queue<T>;
  19.  
  20. int main() {
  21.     IOS;
  22.    
  23.     vector<string> ans{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
  24.     int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  25.     int year[]       = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0}; // 2100,2101,...
  26.     int yearToDate[] = {4, 6, 0, 1, 2, 4, 5, 6, 0, 2, 3, 4, 5, 0, 1, 2, 3, 5, 6, 0, 1, 3, 4};
  27.    
  28.     for (int i = 1; i <= 12; ++i) month[i] += month[i - 1];
  29.    
  30.     int t, y, m, d;
  31.     string s;
  32.     cin >> t;
  33.     while (t--) {
  34.         cin >> s;
  35.         y = stoi(s.substr(0, 4));
  36.         m = stoi(s.substr(5, 2));
  37.         d = stoi(s.substr(8, 2));
  38.        
  39.         // 2112 01 01 Friday
  40.        
  41.         int passed = yearToDate[y - 2100] + month[m - 1] + d - 1;
  42.         if (m > 2) passed += year[y - 2100];
  43.        
  44.         cout << ans[passed % 7] << "\n";
  45.     }
  46.    
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement