# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
999016 | vjudge1 | Datum (COCI20_datum) | C++17 | 51 ms | 596 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |