제출 #845064

#제출 시각아이디문제언어결과실행 시간메모리
845064vjudge1Datum (COCI20_datum)C++17
50 / 50
396 ms60084 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' const int N = 1e6+100, M = 1e5+10, K = 18; string pr(int a, int tp){ string res = to_string(a); if(tp==0 || tp==1) if(res.length() == 2) return res; else return "0"+res; if(res.length() == 4) return res; if(res.length() == 3) return "0"+res; if(res.length() == 2) return "00"+res; return "000"+res; } bool check(array<int, 3>a ){ string s = pr(a[0], 0) + pr(a[1], 1) + pr(a[2], 2); for(int i = 0; i < s.length()/2; ++i) if(s[i] != s[s.length()-1-i]) return false; return 1; } int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; array<int, 3> a; array<int, 3> dp[11000][35][12]; void solve(){ vector<array<int, 3>> cur; a[0] = 0, a[1] = 0, a[2] = 0; cur.pb(a); for(int i = 0; i < 365*11000; ++i){ if(a[0] < month[a[1] - 1]) a[0]++; else if(a[0] >= month[a[1] - 1]){ if(a[1] == 12){ a[0] = 1, a[1] = 1; a[2]++; }else if(a[1] == 2){ if(a[2] % 4 == 0){ if(a[0] == 29){ a[0] = 1; a[1]++; }else{ a[0]++; } }else{ a[0] = 1; a[1]++; } }else{ a[1]++; a[0] = 1; } } if(check(a)){ for(auto k: cur){ dp[k[2]][k[0]][k[1]] = a; } cur.clear(); } cur.pb(a); } int t; cin >> t; for(int i = 0; i < t; ++i){ string s; cin >> s; a[0] = (s[0]-'0')*10 + (s[1]-'0'); a[1] = (s[3]-'0')*10 + (s[4]-'0'); a[2] = (s[6]-'0')*1000 + (s[7]-'0')*100 + (s[8]-'0')*10 + (s[9]-'0'); cout << pr(dp[a[2]][a[0]][a[1]][0], 0) << '.' << pr(dp[a[2]][a[0]][a[1]][1], 1) << '.' << pr(dp[a[2]][a[0]][a[1]][2], 2) << ".\n"; } } int main(){ cin.tie(0); ios::sync_with_stdio(0); int tt = 1, aa; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // cin >> tt; while(tt--){ solve(); // en; } cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

datum.cpp: In function 'std::string pr(int, int)':
datum.cpp:14:5: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   14 |   if(tp==0 || tp==1) if(res.length() == 2) return res; else return "0"+res;
      |     ^
datum.cpp: In function 'bool check(std::array<int, 3>)':
datum.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   for(int i = 0; i < s.length()/2; ++i) if(s[i] != s[s.length()-1-i]) return false;
      |                  ~~^~~~~~~~~~~~~~
datum.cpp: In function 'int main()':
datum.cpp:81:15: warning: unused variable 'aa' [-Wunused-variable]
   81 |   int tt = 1, aa;
      |               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...