// Aber der schlimmste Fiend, dem du begegnen kannst, wirst du immer dir selber sein
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define pb push_back
#define rev reverse
#define all(x) x.begin(),x.end()
#define acc accumulate
#define sz size()
#define MOD 1000000007
#define rall(x) x.rbegin(),x.rend()
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const int N = 2e5 + 5;
int arr[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int check(int d, int m, int y){
m--;
if(d < 1) return 0;
if(m < 12 && d <= arr[m]) return 1;
if(d == 29 && m == 1 && y % 4 == 0) return 1;
return 0;
}
inline void solve(){
string s;
cin >> s;
int year, month, day;
year = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + (s[9] - '0');
int year_in_arr[4];
day = (s[0] - '0') * 10 + (s[1] - '0'), month = (s[3] - '0') * 10 + (s[4] - '0');
year_in_arr[0] = year / 1000;
year %= 1000;
year_in_arr[1] = year / 100;
year %= 100;
year_in_arr[2] = year / 10;
year %= 10;
year_in_arr[3] = year;
year = year_in_arr[0] * 1000 + year_in_arr[1] * 100 + year_in_arr[2] * 10 + year_in_arr[3];
while(1){
int d = year_in_arr[3] * 10 + year_in_arr[2];
int m = year_in_arr[1] * 10 + year_in_arr[0];
int y = year_in_arr[0] * 1000 + year_in_arr[1] * 100 + year_in_arr[2] * 10 + year_in_arr[3];
if(y < year){
}
else if(y == year && m < month){
}
else if(y == year && m == month && d <= day){
}
else if(check(d, m, y)){
cout << year_in_arr[3] << year_in_arr[2] << "." << year_in_arr[1] << year_in_arr[0] << ".";
for(int i = 0; i < 4; i++) cout << year_in_arr[i];
cout << "." << endl;
break;
}
if(++year_in_arr[3] == 10) year_in_arr[3] = 0, year_in_arr[2]++;
if(year_in_arr[2] == 10) year_in_arr[2] = 0, year_in_arr[1]++;
if(year_in_arr[1] == 10) year_in_arr[1] = 0, year_in_arr[0]++;
}
}
int main(){
fast_io
int t;
cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
30 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
29 ms |
344 KB |
Output is correct |