Submission #845139

# Submission time Handle Problem Language Result Execution time Memory
845139 2023-09-06T12:13:12 Z vjudge1 Datum (COCI20_datum) C++
20 / 50
24 ms 348 KB
#include <iostream>
#include <algorithm>
using namespace std;


int main(){
    int t, curryear, ansyear, month, day;
    int daysinmonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    bool isvalid;
    bool isfirst;
    string s, ansstr;
    cin >> t;
    for (int tt = 0; tt < t ; tt++){
        cin >> s;
        curryear = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + (s[9] - '0');
        ansyear = curryear;
        isvalid = false;
        isfirst = true;
        while (!isvalid){
            isvalid = true;
            month = ((ansyear % 1000) / 100) * 10 + ansyear / 1000;
            day = (ansyear % 10) * 10 + (ansyear % 100) / 10;
            if (month == 0 || month > 12){
                isvalid = false;
                ansyear++;
                continue;
            }
            if (day < 1){
                isvalid = false;
                ansyear++;
                continue;
            }
            if (month == 2 && curryear % 4 == 0 && day > 29){
                isvalid = false;
                ansyear++;
                continue;
            }
            if ((month != 2 || curryear % 4 != 0) && day > daysinmonth[month - 1]){
                isvalid = false;
                ansyear++;
                continue;
            }
            if (isfirst){
                isfirst = false;
                if (month < (s[3] - '0') * 10 + (s[4] - '0') || (month == (s[3] - '0') * 10 + (s[4] - '0') && day <= (s[0] - '0') * 10 + (s[1] - '0'))){
                    isvalid = false;
                    ansyear++;
                    continue;
                }
            }
        }
        ansstr = "00.00.0000.\n";
        ansstr[0] = '0' + (char) (ansyear % 10);
        ansstr[1] = '0' + (char) ((ansyear / 10) % 10);
        ansstr[3] = '0' + (char) ((ansyear / 100) % 10);
        ansstr[4] = '0' + (char) (ansyear / 1000);
        ansstr[9] = '0' + (char) (ansyear % 10);
        ansstr[8] = '0' + (char) ((ansyear / 10) % 10);
        ansstr[7] = '0' + (char) ((ansyear / 100) % 10);
        ansstr[6] = '0' + (char) (ansyear / 1000);
        cout << ansstr;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 24 ms 344 KB Output isn't correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 0 ms 344 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 0 ms 344 KB Output isn't correct
10 Incorrect 24 ms 344 KB Output isn't correct