#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define OPEN freopen(".in", "r", stdin); \
freopen(".out", "w", stdout);
#else
#define OPEN void(23);
#endif
set <int> vec;
int months[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int toint(string &a)
{
int val = 0;
for(char &ch : a) val = val * 10 + (ch - '0');
return val;
}
void precalc()
{
for(int i = 1; i <= 12; i++)
{
for(int j = 1; j <= months[i]; j++)
{
int year = j / 10 + (j % 10) * 10 + (i / 10) * 100 + (i % 10) * 1000;
vec.emplace(year * 10000 + i * 100 + j);
}
}
}
void solve()
{
string date; cin >> date;
int day = 0, month = 0, year = 0;
for(int i = 1; i <= 2; i++) day = day * 10 + date[0 + i -1] - '0';
for(int i = 1; i <= 2; i++) month = month * 10 + date[3 + i -1] - '0';
for(int i = 1; i <= 4; i++) year = year * 10 + date[6 + i -1] - '0';
auto it = vec.upper_bound(year * 10000 + month * 100 + day);
int _year = *it / 10000;
int _month = (*it / 100) % 100;
int _day = *it % 100;
cerr << day << '.' << month << '.' << year << ".\n";
if(_day <= 9) cout << '0';
cout << _day << '.';
if(_month <= 9) cout << '0';
cout << _month << '.';
if(_year <= 9) cout << '0';
if(_year <= 99) cout << '0';
if(_year <= 999) cout << '0';
cout << _year << '.';
cout << "\n";
return;
}
int32_t main()
{
OPEN;
precalc();
//for(const int &i : vec) cerr << i << " ";
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1; cin >> t;
while(t--)
{
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
79 ms |
508 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
78 ms |
500 KB |
Output is correct |