# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
238415 |
2020-06-11T07:09:41 Z |
stev2005 |
Datum (COCI20_datum) |
C++17 |
|
62 ms |
632 KB |
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;
/*struct date
{
string d,m,y;
void input()
{
cin>>d;
}
};
date in,ans;*/
string in,ans;
int d,y,m,n;
void init()
{
/*day: 0-1
month: 3-4
year: 6-9*/
d=((int)in[0]-(int)'0')*10+((int)in[1]-(int)'0');
m=((int)in[3]-(int)'0')*10+((int)in[4]-(int)'0');
y=((int)in[6]-(int)'0')*1000+((int)in[7]-(int)'0')*100;
y+=(((int)in[8]-(int)'0')*10+((int)in[9]-(int)'0'));
}
bool check(int ty)
{
if(d==0||m==0)return false;
/// 31: 1,3,5,7,8,10,12
if(m>12)return false;
if(m==2)
{
if(d<=28)return true;
else
{
if(d<=29)
{
if(ty%4==0)return true;
else return false;
}
else return false;
}
}
if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
{
if(d<=31)return true;
else return false;
}
else
{
if(d<=30)return true;
else return false;
}
}
void solve()
{
int ed,des,st,hil;
for(int i=y+1;i<=9999;i++)
{
ed=i%10;
des=i/10%10;
st=i/100%10;
hil=i/1000%10;
d=ed*10+des;
m=hil+st*10;
if(check(i))
{
y=i;
return;
}
}
}
void print()
{
string ans="",t="";
char c;
c=((char)(d/10%10+(int)'0'));
ans+=c;
c=((char)(d%10+(int)'0'));
ans+=c;ans+='.';
c=((char)(m/10%10+(int)'0'));
ans+=c;
c=((char)(m%10+(int)'0'));
ans+=c;ans+='.';
c=((char)(y/1000%10+(int)'0'));
ans+=c;
c=((char)(y/100%10+(int)'0'));
ans+=c;
c=((char)(y/10%10+(int)'0'));
ans+=c;
c=((char)(y%10+(int)'0'));
ans+=c;ans+='.';
cout<<ans<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=0;i<n;i++)
{
cin>>in;
init();
solve();
print();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
61 ms |
632 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Incorrect |
62 ms |
504 KB |
Output isn't correct |