제출 #1333548

#제출 시각아이디문제언어결과실행 시간메모리
1333548ahmetlbktd4Datum (COCI20_datum)C++20
50 / 50
16 ms464 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 ok(int m,int y){
    int ay[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    if (m == 2 && y%4==0)
    return 29;
    return ay[m];
}

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';
        while (1){
            int a = y/100;
            int b = y%100;
            int m1 = (a%10)*10+(a/10); 
            int d1 = (b%10)*10+(b/10);
            if (m1 >= 1 && m1 <= 12 && d1 > 0 && d1 <= ok(m1,y)){
                if(y>stoi(s.substr(6,4)) || (y==stoi(s.substr(6,4)) && (m1>m || (m1==m && d1>d)))){
                cout << setw(2) << setfill('0') << d1 << ".";
                cout << setw(2) << setfill('0') << m1 << ".";
                cout << setw(4) << setfill('0') << y << ".\n";
                break;
                }
            } 
            y++;
        }
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...