# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
584254 | AGE | Datum (COCI20_datum) | C++14 | 1094 ms | 31572 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>
#define F first
#define S second
#define pb push_back
#define ll long long
using namespace std;
const int N=1e6,M=1502,mod=1e9+7,p=31;
int year,month,day;
int a[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s[N];
main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
cin>>s[i];
for(int i=0;i<n;i++){
year=0,day=0,month=0;
for(int j=s[i].size()-5;j<=s[i].size()-2;j++){
year+=(s[i][j]-'0');
year*=10;
}
year/=10;
month=s[i][s[i].size()-8]-'0';
month*=10;
month+=(s[i][s[i].size()-7])-'0';
day=s[i][0]-'0';
day*=10;
day+=(s[i][1]-'0');
while(1){
vector<int>v;
int x=a[month];
if(month==2&&year%4==0)
x--;
day++;
if(day>x)
day=1,month++;
if(month>12)
month=1,year++;
if(day<10)
v.pb(0);
if(day>=10)
v.pb(day/10);
v.pb(day%10);
if(month<10)
v.pb(0);
if(month>=10)
v.pb((month/10));
v.pb(month%10);
if(year<10000)
v.pb(0);
if(year<1000)
v.pb(0);
if(year<100)
v.pb(0);
if(year>=1000)
v.pb((year/1000));
if(year>=100)
v.pb((year/100)%10);
if(year>=10)
v.pb((year/10)%10);
v.pb(year%10);
int ok=0;
for(int i=0;i<v.size()/2;i++)
if(v[i]!=v[v.size()-1-i])
ok=1;
if(ok==0)
break;
}
vector<char>vv;
if(day<10)
vv.pb('0');
if(day>=10)
vv.pb(day/10+'0');
vv.pb(day%10+'0');
vv.pb('.');
if(month<10)
vv.pb(0+'0');
if(month%10==0)
vv.pb((month/10)+'0');
vv.pb(month%10+'0');
vv.pb('.');
if(year<1000)
vv.pb(0+'0');
if(year<100)
vv.pb(0+'0');
if(year>=1000)
vv.pb((year/1000)+'0');
if(year>=100)
vv.pb((year/100)%10+'0');
if(year>=10)
vv.pb((year/10)%10+'0');
vv.pb(year%10+'0');
vv.pb('.');
for(int i=0;i<vv.size();i++)
cout<<vv[i];
cout<<endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |