답안 #845583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845583 2023-09-06T14:17:37 Z vjudge1 Datum (COCI20_datum) C++17
50 / 50
24 ms 604 KB
#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define spc << " " <<
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007

using namespace std;





void solve(){
    string s; cin >> s;
    int yea=(s[6]-'0')*1000 + (s[7]-'0')*100 + (s[8]-'0')*10 + (s[9]-'0');
    int mon=(s[3]-'0')*10 + (s[4]-'0');
    int day=(s[0]-'0')*10 + (s[1]-'0');
    for(int n=yea; n<=9999; n++){
        int d1=n/1000, d2=(n%1000)/100, d3=(n%100)/10, d4=n%10;
        int nmon=(d2*10)+d1;
        if(nmon>12 || nmon==0 || (n==yea && nmon<mon)) continue;
        int nday=(d4*10)+d3;
        if(nday>31 || nday==0 || (n==yea && nmon==mon && nday<=day)) continue;
        if((nmon==4 || nmon==6 || nmon==9 || nmon==11) && nday>30) continue;
        if(n%4==0){
            if(nmon==2 && nday>29) continue;
        }
        else{
            if(nmon==2 && nday>28) continue;
        }
        cout << d4 << d3 << "." << d2 << d1 << "." << d1 << d2 << d3 << d4 << "." << endl;
        return;
    }
    cout << "we failed :(" << endl;
}



signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out","w",stdout);
    #endif
    

    ll t=1;
    cin >> t;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 24 ms 600 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 23 ms 604 KB Output is correct