# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
520240 | KoD | Datum (COCI20_datum) | C++17 | 21 ms | 528 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |