#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;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
33 ms |
384 KB |
Output isn't correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Incorrect |
33 ms |
504 KB |
Output isn't correct |