Submission #845583

#TimeUsernameProblemLanguageResultExecution timeMemory
845583vjudge1Datum (COCI20_datum)C++17
50 / 50
24 ms604 KiB
#pragma GCC optimize("unroll-loops,Ofast,O3") #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define spc << " " << #define all(x) x.begin(), x.end() #define ll long long #define int long long #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define st first #define nd second #define inf 1000000009 #define MOD 1000000007 using namespace std; void solve(){ string s; cin >> s; int yea=(s[6]-'0')*1000 + (s[7]-'0')*100 + (s[8]-'0')*10 + (s[9]-'0'); int mon=(s[3]-'0')*10 + (s[4]-'0'); int day=(s[0]-'0')*10 + (s[1]-'0'); for(int n=yea; n<=9999; n++){ int d1=n/1000, d2=(n%1000)/100, d3=(n%100)/10, d4=n%10; int nmon=(d2*10)+d1; if(nmon>12 || nmon==0 || (n==yea && nmon<mon)) continue; int nday=(d4*10)+d3; if(nday>31 || nday==0 || (n==yea && nmon==mon && nday<=day)) continue; if((nmon==4 || nmon==6 || nmon==9 || nmon==11) && nday>30) continue; if(n%4==0){ if(nmon==2 && nday>29) continue; } else{ if(nmon==2 && nday>28) continue; } cout << d4 << d3 << "." << d2 << d1 << "." << d1 << d2 << d3 << d4 << "." << endl; return; } cout << "we failed :(" << endl; } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); #ifdef Local freopen("in.txt","r",stdin); freopen("out","w",stdout); #endif ll t=1; cin >> t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...