Submission #520240

#TimeUsernameProblemLanguageResultExecution timeMemory
520240KoDDatum (COCI20_datum)C++17
50 / 50
21 ms528 KiB
#include <bits/stdc++.h> using std::vector; using std::array; using std::tuple; using std::pair; int read(int len) { int ret = 0; while (len--) { char c; std::cin >> c; ret = 10 * ret + (c - '0'); } return ret; } void ignore() { char c; std::cin >> c; } constexpr int memo[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int N; std::cin >> N; vector<tuple<int, int, int>> good; for (int a = 0; a < 10; ++a) { for (int b = 0; b < 10; ++b) { for (int c = 0; c < 10; ++c) { for (int d = 0; d < 10; ++d) { int year = 1000 * a + 100 * b + 10 * c + 1 * d; int day = 10 * d + 1 * c; int month = 10 * b + 1 * a; if (month < 1 or 12 < month) { continue; } if (day < 1 or memo[month - 1] + (year % 4 == 0 and month == 2) < day) { continue; } good.emplace_back(year, month, day); } } } } while (N--) { int day = read(2); ignore(); int month = read(2); ignore(); int year = read(4); ignore(); const auto [y, m, d] = *std::upper_bound(good.begin(), good.end(), std::make_tuple(year, month, day)); std::cout << std::setw(2) << std::setfill('0') << d << '.'; std::cout << std::setw(2) << std::setfill('0') << m << '.'; std::cout << std::setw(4) << std::setfill('0') << y << ".\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...