# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238494 | Salito | Datum (COCI20_datum) | C++14 | 38 ms | 384 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;
int month(int y,int m)
{
if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)
return 3;
if(m!=2)return 2;
return !y%4;
}
void solve(string s)
{
int d,m,y1,y2,y;
d=(s[0]-'0')*10+s[1]-'0';
m=(s[3]-'0')*10+s[4]-'0';
y1=(s[7]-'0')*10+s[6]-'0';
y2=(s[9]-'0')*10+s[8]-'0';
y=(s[8]-'0')*10+s[9]-'0';
/* if(m == y1 && d < y2 && y2 <= 28 + month(y,m))
{
if(y2<10)cout<<0;
cout<<y2<<".";
if(m<10)cout<<0;
cout<<m<<"."<<s[6]<<s[7]<<s[8]<<s[9]<<".\n";
return ;
}
if(d == y2 && m < y1 && y1<=12)
{
if(d<10)cout<<0;
cout<<d<<".";
if(y1<10)cout<<0;
cout<<y1<<"."<<s[6]<<s[7]<<s[8]<<s[9]<<".\n";
return ;
}
if((d < y2 && y2 <= 28 + month(y,y1)) && (m < y1 && y1<=12))
{
if(y2<10)cout<<0;
cout<<y2<<".";
if(y1<10)cout<<0;
cout<<y1<<"."<<s[6]<<s[7]<<s[8]<<s[9]<<".\n";
return ;
}*/
if(y1>12)
{
y = (s[6]-'0')*10+s[7]-'0';
do
{
y++;
y1 = (y%10) *10 + y/10;
}while(y1 >12);
cout<<"10.";
if(y1<10)
cout<<"0";
cout<<y1<<".";
if(y<10)cout<<"0";
cout<<y<<"01.\n";
return ;
}
y1=(s[6]-'0')*10+s[7]-'0';
y2=(s[8]-'0')*10+s[9]-'0';
m = (y1%10) *10 + y1/10;
if(m/10 == s[3]-'0' && m%10 == s[4]-'0')y2++;
do
{
int ry;
ry = (y2%10) *10 + y2/10;
if(ry <= 28 +month(y2,m))
{
if(ry<10)
cout<<0;
cout<<ry<<".";
if(m<10)cout<<0;
cout<<m<<".";
if(y1<10)cout<<0;
cout<<y1;
if(y2<10)cout<<0;
cout<<y2<<".\n";
return ;
}
y2++;
}while(y<100);
y = (s[6]-'0')*10+s[7]-'0';
do
{
y++;
y1 = (y%10) *10 + y/10;
}while(y1 >12);
cout<<"10.";
if(y1<10)
cout<<"0";
cout<<y1<<".";
if(y<10)cout<<"0";
cout<<y<<"01.\n";
return ;
}
int main()
{
string s;
int n,i;
cin>>n;
for(i=0;i<n;i++)
{
cin>>s;
solve(s);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |