# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845259 |
2023-09-06T12:51:57 Z |
vjudge1 |
Datum (COCI20_datum) |
C++17 |
|
6 ms |
348 KB |
// author: erray
#include <bits/stdc++.h>
#ifdef DEBUG
#include "debug.h"
#else
#define debug(...) void(37)
#endif
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int TT;
cin >> TT;
while (TT--) {
string D;
cin >> D;
int cur = 0, year = 0;
auto C = [&](char c) {
return c - '0';
};
cur = C(D[0]) + 10 * C(D[1]) + 100 * C(D[3]) + 1000 * C(D[4]);
for (int i = 0, pw = 1; i < 4; ++i, pw *= 10) {
year += pw * C(D.end()[-i - 2]);
}
debug(cur, year);
auto Find = [&](int y) {
auto Day = [&](int x) {
int r = x % 100;
return r % 10 * 10 + (r / 10);
};
auto Month = [&](int x) {
int r = x / 100;
return r % 10 * 10 + (r / 10);
};
auto Leap = [&](int x) {
return x % 4 == 0;
};
constexpr int days[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
auto Valid = [&](int x) {
int m = Month(x);
return m <= 12 && m > 0 && (days[m] + (m == 2 && Leap(x)) >= Day(x));
};
debug("here");
for (int add = 0; add < 100; ++add) {
if (Valid(y + add)) {
return y + add;
}
}
debug("bad");
y -= y % 100;
y += 1;
while (Month(y) > 12 || Month(y) == 0) {
y += 100;
}
debug(y);
assert(Valid(y));
return y;
//divisible by 4 but not 100
};
int ans = Find(year);
if (ans == year && cur >= year) {
ans = Find(year + 1);
}
debug(ans);
string res;
string yts = to_string(ans);
while (yts.size() < 4) {
yts.insert(yts.begin(), '0');
}
debug(D, yts);
res += yts;
reverse(res.begin(), res.end());
res += yts;
res.insert(res.begin() + 2, '.');
res.insert(res.begin() + 5, '.');
res.insert(res.end(), '.');
cout << res << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
6 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Incorrect |
4 ms |
348 KB |
Output isn't correct |