Submission #998996

#TimeUsernameProblemLanguageResultExecution timeMemory
998996vjudge1Datum (COCI20_datum)C++17
50 / 50
68 ms504 KiB
#include <bits/stdc++.h> using namespace std; int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<int, string> str; map<string, int> num; vector<int> vec; void solve(){ string s; cin >> s; int MM = (s[3] - '0') * 10 + (s[4] - '0'); int DD = (s[0] - '0') * 10 + (s[1] - '0'); int Y = ((((((s[6] - '0') * 10) + (s[7] - '0')) * 10) + (s[8] - '0')) * 10) + (s[9] - '0'); for (int year = Y; year < 10000; year ++){ string y = to_string(year); while (y.size() < 4) y = '0' + y; int d = (y[3] - '0') * 10 + (y[2] - '0'); int m = (y[1] - '0') * 10 + (y[0] - '0'); if (m == 0 or m > 12) continue; if (d == 0 or days[m - 1] < d) continue; string dd = to_string(d); while (dd.size() < 2) dd = '0' + dd; string mm = to_string(m); while (mm.size() < 2) mm = '0' + mm; if (year > Y or (year == Y and (m > MM or (m == MM and d > DD)))){ cout << dd << '.' << mm << '.' << y << '.' << endl; return; } } } int main(){ int t; cin >> t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...