Submission #999014

# Submission time Handle Problem Language Result Execution time Memory
999014 2024-06-15T05:01:22 Z vjudge1 Datum (COCI20_datum) C++17
5 / 50
56 ms 608 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
int const N=10005;
int const mod=1e9+7;

bool year[N];
int mon[N];
int dt[N];
bool leaf(int y){
    return (y%4==0);
}

bool check1(int y){
    string yr=to_string(y);
    while(yr.length()<4)
        yr='0'+yr;
    int d=((yr[3]-'0')*10)+(yr[2]-'0');
    int m=((yr[1]-'0')*10)+(yr[0]-'0');
    if(m>12 || m<=0 || d<=0)
        return 0;
    int dm[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31};
    dm[2]+=leaf(y);
    if(d<=dm[m] && d>0){
        mon[y]=m;
        dt[y]=d;
        return 1;
    }
    return 0;
}

void solve(){
    string date;
    cin>>date;
    int y=((date[6]-'0')*1000)+((date[7]-'0')*100)+((date[8]-'0')*10)+(date[9]-'0');
    int m=((date[3]-'0')*10)+(date[4]-'0');
    int d=((date[0]-'0')*10)+(date[1]-'0');
    int ans_y=9999;
    // cout<<y<<endl;
    if(year[y]){
        if(m>mon[y])
            ans_y=y;
        if(mon[y]==m && d>dt[y])
            ans_y=y;
    }
    for(int i=y+1;i<=9999;i++)
        if(year[i])
            ans_y=min(i,ans_y);
    string ay=to_string(ans_y);
    while(ay.length()<4)
        ay='0'+ay;

    cout<<ay[3]<<ay[2]<<'.'<<ay[1]<<ay[0]<<'.'<<ay<<'.'<<endl;
}

int main(){
    for(int i=1;i<=9999;i++){
        year[i]=check1(i);
        // if(year[i])
            // cout<<dt[i]<<'.'<<mon[i]<<'.'<<i<<endl;
    }
    int t=1;
    cin>>t;
    while(t--)
        solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 52 ms 596 KB Output isn't correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Incorrect 1 ms 344 KB Output isn't correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 56 ms 608 KB Output isn't correct