# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
845154 |
2023-09-06T12:18:54 Z |
vjudge1 |
Datum (COCI20_datum) |
C++17 |
|
299 ms |
704 KB |
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n";
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 200005
const int modulo = 1e9 + 7;
vector<int> v = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int steps = 0;
array<int, 3> palindrom(int y){
vector<int> v;
int tmp = y;
for (int i = 0; i < 4; i++){
v.pb(tmp % 10);
tmp /= 10;
}
array<int, 3> date;
date[0] = v[0] * 10 + v[1];
date[1] = v[2] * 10 + v[3];
date[2]= y;
return date;
}
bool comp(array<int, 3> a, array<int, 3> b){
reverse(a.begin(), a.end()), reverse(b.begin(), b.end());
return a < b;
}
bool check(array<int, 3> &date){
if (date[1] > 12 || date[1] == 0 || date[0] == 0) return 0;
int lim = v[date[1] - 1];
if (date[1] == 2 && date[2] % 4 == 0) lim = 29;
if (date[0] > lim) return 0;
return 1;
}
void print(array<int, 3> ans){
cout<<(ans[0] < 10 ? "0" : "")<<ans[0]<<"."<<(ans[1] < 10 ? "0" : "")<<ans[1]<<".";
if (ans[2] < 1000) cout<<"0";
if (ans[2] < 100) cout<<"0";
if (ans[2] < 10) cout<<"0";
cout<<ans[2]<<"."<<endl;
}
int32_t main()
{
fastio();
int n;
cin>>n;
while(n--){
string s;
cin>>s;
array<int, 3> date = {(s[0] - '0') * 10 + s[1] - '0', (s[3] - '0') * 10 + s[4] - '0',
(s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + s[9] - '0'};
for (int i = date[2]; i < 10000; i++){
array<int, 3> curr = palindrom(i);
if ((comp(date, curr)) && check(curr)){
print(curr);
break;
}
}
}
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " seconds\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
290 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
299 ms |
704 KB |
Output is correct |