Submission #1333528

#TimeUsernameProblemLanguageResultExecution timeMemory
1333528ahmetlbktd4Datum (COCI20_datum)C++20
0 / 50
1095 ms436 KiB
#include "bits/stdc++.h"
using namespace std;

bool ok(int d,int m,int y){
    string d1 = to_string(d),m1 = to_string(m),y1 = to_string(y);
    if (d < 10)
    d1 = "0" + d1;
    if (m < 10)
    m1 = "0" + m1;
    while (y1.size() < 4)
    y1 = "0" + y1;
    string s = d1+m1+y1;
    string p = s;
    reverse(p.begin(),p.end());
    // cout << p << " " << s << "\n";
    return p == s;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    // cout << ok(3,2,2030) << "-->\n";
    while (t--){
        string s;
        cin >> s;
        int ay[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        int d = (s[0]-'0')*10+s[1]-'0';
        int m = (s[3]-'0')*10+s[4]-'0';
        int y = (s[6]-'0')*1000+(s[7]-'0')*100+(s[8]-'0')*10+s[9]-'0';
        if (y%400==0 or (y%100 and y%4==0))
        ay[2] = 29;
        else ay[2] = 28;
        while (1){
            if (y%400==0 or (y%100 and y%4==0))
            ay[2] = 29;
            else ay[2] = 28;
            d++;
            if (d > ay[m]){
                m++;
                d = 1;
            }
            if (m > 12){
                m=1;y++;
            }
            if (ok(d,m,y))
            break;
        } 
        cout << (d < 10 ? "0" : "") <<  d << "." << (m<10 ? "0" : "") << m << ".";
        string y1 = to_string(y);
        while (y1.size() < 4){
            y1="0"+y1;
        }
        cout << y1 << "\n";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...