# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
238459 |
2020-06-11T12:08:33 Z |
vankata |
Datum (COCI20_datum) |
C++14 |
|
61 ms |
384 KB |
#include<bits/stdc++.h>
using namespace std;
void print(int a,int b,int c)
{
if(a<10)cout<<0;
cout<<a;
cout<<".";
if(b<10)cout<<0;
cout<<b;
cout<<".";
if(c<1000)cout<<0;
cout<<c;
cout<<".\n";
}
bool adequate(int d,int m,int y)
{
if(d>31||m>12||m==0||d==0)return false;
if(m==2)
{
if(y%4==0)
{
if(d>29)return false;
}
else if(d>28)return false;
}
else
{
if(m==4||m==6||m==9||m==11)
{
if(d>30)return false;
}
else if (d>31)return false;
}return true;
}
void solve()
{
string s;
cin>>s;
int d=0,a,b,l=0,i;
int m=0;
int y=0;
for(i=0; i<s.size(); i++)
{
if(s[i]=='.')l++;
else
{
if(l==0)
{
d*=10;
d+=s[i]-'0';
}
else if(l==1)
{
m*=10;
m+=s[i]-'0';
}
else
{
y*=10;
y+=s[i]-'0';
}
}
}
for(i=max(y,100); i<=9299; i++)
{
l=i;
a=l%10;
a*=10;l/=10;
a+=l%10;
l/=10;
b=l%10;
b*=10;l/=10;
b+=l;
if(a==d&&b==m&&i==y)continue;
if(adequate(a,b,i))
{
print(a,b,i);
break;
}
}
}
int main()
{
int n;
cin>>n;
while(n--)solve();
return 0;
}
Compilation message
datum.cpp: In function 'void solve()':
datum.cpp:43:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0; i<s.size(); i++)
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Incorrect |
59 ms |
384 KB |
Output isn't correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
4 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 |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Incorrect |
61 ms |
384 KB |
Output isn't correct |