Submission #998977

#TimeUsernameProblemLanguageResultExecution timeMemory
998977vjudge1Datum (COCI20_datum)C++17
35 / 50
315 ms528 KiB
#include <bits/stdc++.h> using namespace std; map<string,string> mp; void pr(string s,string t,string y) { cout<<s<<'.'<<t<<'.'<<y<<".\n"; } pair<string,string> get(string y) { reverse(y.begin(),y.end()); pair<string,string> p={y.substr(0,2),y.substr(2,2)}; return p; } bool leap(string y) { int y1=stoi(y); return y1%4; } void add(string &y) { int y1=stoi(y); y1++; y=to_string(y1); while (y.size()<4) y='0'+y; } bool valid(pair<string,string> p,string y) { if (p.second>"12" or p.second=="00" or p.first=="00" or !(mp[p.second]>=p.first or (leap(y) && p.first=="29"))) return false; return true; } int main() { int t; cin>>t; int a[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31}; for (int i=1;i<=12;i++) { string wh=to_string(i); if (wh.size()<2) wh='0'+wh; mp[wh]=to_string(a[i-1]); } while (t--) { string dd; cin>>dd; string d=dd.substr(0,2); string m=dd.substr(3,2); string y=dd.substr(6,4); pair<string,string> p=get(y); if ((p.second>m or p.first>d) && valid(p,y)) { pr(p.first,p.second,y); continue; } while (1) { add(y); pair<string,string> p=get(y); if (valid(p,y)) { pr(p.first,p.second,y); break; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...