/**
* author: kututay
* created: 06.09.2023 14:29:47
**/
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "/Users/kutay/CP/templates/debug.h"
#else
#define debug(...) void(38)
#endif
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0);
auto check = [](int d, int m, int y) {
string s = (d < 10 ? "0" + to_string(d) : to_string(d));
s += (m < 10 ? "0" + to_string(m) : to_string(m));
for (int i = 0; i < 4 - (int) to_string(y).size(); i++) {
s += "0";
}
s += to_string(y);
for (int i = 0; i <= (int) s.size() / 2; i++) {
if (s[i] != s[(int) s.size() - i - 1]) return false;
}
return true;
};
vector<int> dd = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<pair<pair<int, int>, pair<int, int>>> v;
int d = 1, m = 1, y = 1;
for (int day = 1; day < 4000000; day++) {
if (y > 9999) break;
if (check(d, m, y)) {
v.push_back(make_pair(make_pair(day, d), make_pair(m, y)));
}
bool flag = false;
if (y % 4 == 0) {
dd[1] = 29;
flag = true;
}
d++;
if (d > dd[m - 1]) {
m++;
d = 1;
}
if (m > 12) {
y++;
m = 1;
}
if (flag) dd[1] = 28;
}
// debug(v);
int t; cin >> t;
while (t--) {
string s; cin >> s;
d = stoi(s.substr(0, 2)), m = stoi(s.substr(3, 2)), y = stoi(s.substr(6, 4));
int day = d;
if (y % 4 == 0) dd[1] = 29;
for (int i = 0; i < m - 1; i++) {
day += dd[i];
}
day += (y / 4) + y * 365;
auto it = v[lower_bound(v.begin(), v.end(), make_pair(make_pair(day, 1), make_pair(1, 1))) - v.begin()];
d = it.first.second, m = it.second.first, y = it.second.second;
s = (d < 10 ? "0" + to_string(d) : to_string(d)) + ".";
s += (m < 10 ? "0" + to_string(m) : to_string(m)) + ".";
for (int i = 0; i < 4 - (int) to_string(y).size(); i++) {
s += "0";
}
s += to_string(y) + ".";
cout << s << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
208 ms |
436 KB |
Output isn't correct |
2 |
Incorrect |
217 ms |
444 KB |
Output isn't correct |
3 |
Incorrect |
210 ms |
600 KB |
Output isn't correct |
4 |
Incorrect |
210 ms |
448 KB |
Output isn't correct |
5 |
Incorrect |
213 ms |
440 KB |
Output isn't correct |
6 |
Incorrect |
208 ms |
696 KB |
Output isn't correct |
7 |
Incorrect |
208 ms |
432 KB |
Output isn't correct |
8 |
Correct |
205 ms |
444 KB |
Output is correct |
9 |
Correct |
208 ms |
436 KB |
Output is correct |
10 |
Incorrect |
216 ms |
456 KB |
Output isn't correct |