Submission #238446

# Submission time Handle Problem Language Result Execution time Memory
238446 2020-06-11T11:01:01 Z vankata Datum (COCI20_datum) C++14
35 / 50
59 ms 504 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 a,int b,int c)
{
    if(b>12||b==0)return false;
    if(a>31||a==0)return false;
    if(b==2)
    {
        if(c%4==0)return a<=29;
        else return a<=28;
    }
    if(b==4||b==6||b==9||b==11)
    {
        return a<=30;
    }
    return true;
}
void solve()
{
    string s;
    cin>>s;
    int d,a,b,l,i;
    int m;
    int y;
    d = (s[0]-'0')*10+(s[1]-'0');
    m = (s[3]-'0')*10+(s[4]-'0');
    y = (((s[6]-'0')*10+(s[7]-'0'))*10+(s[8]-'0'))*10+(s[9]-'0');
    for(i=max(y,100); i<=9999; i++)
    {
        l=i;
        a=l%10;
        l/=10;
        a*=10;
        a+=l%10;
        l/=10;

        b=l%10;
        b*=10;
        l/=10;
        b+=l%10;

        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;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 58 ms 384 KB Output isn't correct
3 Correct 5 ms 128 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Incorrect 4 ms 384 KB Output isn't correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Incorrect 59 ms 504 KB Output isn't correct