Submission #999016

#TimeUsernameProblemLanguageResultExecution timeMemory
999016vjudge1Datum (COCI20_datum)C++17
20 / 50
51 ms596 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=10005; int const mod=1e9+7; bool year[N]; int mon[N]; int dt[N]; bool leaf(int y){ return (y%4==0); } bool check1(int y){ string yr=to_string(y); while(yr.length()<4) yr='0'+yr; int d=((yr[3]-'0')*10)+(yr[2]-'0'); int m=((yr[1]-'0')*10)+(yr[0]-'0'); if(m>12 || m<=0 || d<=0) return 0; int dm[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31}; dm[2]+=leaf(y); if(d<=dm[m] && d>0){ mon[y]=m; dt[y]=d; return 1; } return 0; } void solve(){ string date; cin>>date; int y=((date[6]-'0')*1000)+((date[7]-'0')*100)+((date[8]-'0')*10)+(date[9]-'0'); int m=((date[3]-'0')*10)+(date[4]-'0'); int d=((date[0]-'0')*10)+(date[1]-'0'); int ans_y=9999; // cout<<y<<endl; // cout<<d<<' '<<m<<' '<<y<<endl; if(year[y]){ // cout<<dt[y]<<' '<<mon[y]<<endl; if(m<mon[y]) ans_y=y; if(mon[y]==m && d<dt[y]) ans_y=y; } for(int i=y+1;i<=9999;i++) if(year[i]) ans_y=min(i,ans_y); string ay=to_string(ans_y); while(ay.length()<4) ay='0'+ay; cout<<ay[3]<<ay[2]<<'.'<<ay[1]<<ay[0]<<'.'<<ay<<'.'<<endl; // cout<<"----------------------"<<endl; } int main(){ for(int i=1;i<=9999;i++){ year[i]=check1(i); // if(year[i]) // cout<<dt[i]<<'.'<<mon[i]<<'.'<<i<<endl; } int t=1; cin>>t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...