# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845144 |
2023-09-06T12:14:37 Z |
vjudge1 |
Datum (COCI20_datum) |
C++17 |
|
1000 ms |
247100 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
auto tos = [&](int day, int month, int year) {
string a = to_string(day);
string b = to_string(month);
string c = to_string(year);
if (a.size() != 2) {
a = string(1, '0') + a;
}
if (b.size() != 2) {
b = string(1, '0') + b;
}
if (c.size() != 4) {
c = string(4 - c.size(), '0') + c;
}
return a + b + c;
};
auto pal = [&](int day, int month, int year) {
string d = tos(day, month, year);
string e = d;
reverse(e.begin(), e.end());
return d == e;
};
vector<int> last = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
auto max_day = [&](int m, int year) {
return last[m-1] + (m == 2 && year % 4 == 0);
};
array<int, 3> lastp = {1, 1, 1};
map<array<int, 3>, string> get;
int day = 31, month = 12, year = 9999;
while (year >= 0) {
get[{day, month, year}] = tos(lastp[0], lastp[1], lastp[2]);
if (pal(day, month, year)) {
get[{day, month, year}] = tos(lastp[0], lastp[1], lastp[2]);
lastp = {day, month, year};
}
day -= 1;
if (day <= 0) {
month -= 1;
if (month > 0) {
day = max_day(month, year);
}
}
if (month <= 0) {
year -= 1;
month = 12;
day = 31;
}
}
while (t--) {
string date;
cin >> date;
day = (date[0]-'0')*10 + (date[1]-'0');
month = (date[3]-'0')*10 + (date[4]-'0');
year = (date[6]-'0')*1000 + (date[7]-'0')*100 + (date[8]-'0') * 10 + (date[9]-'0');
string ans = get[{day, month, year}];
ans.insert(ans.begin()+2, '.');
ans.insert(ans.begin()+5, '.');
ans.push_back('.');
cout << ans << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1031 ms |
231760 KB |
Time limit exceeded |
2 |
Execution timed out |
1029 ms |
228520 KB |
Time limit exceeded |
3 |
Execution timed out |
1081 ms |
242772 KB |
Time limit exceeded |
4 |
Execution timed out |
1084 ms |
240800 KB |
Time limit exceeded |
5 |
Execution timed out |
1090 ms |
247100 KB |
Time limit exceeded |
6 |
Execution timed out |
1082 ms |
246100 KB |
Time limit exceeded |
7 |
Execution timed out |
1072 ms |
240832 KB |
Time limit exceeded |
8 |
Execution timed out |
1053 ms |
233472 KB |
Time limit exceeded |
9 |
Execution timed out |
1074 ms |
242084 KB |
Time limit exceeded |
10 |
Execution timed out |
1093 ms |
246504 KB |
Time limit exceeded |