#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 200005
using namespace std;
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // 2.'ye dikkat
bool isLegit(int d, int m, bool leap) {
bool ret = 0;
if(leap) days[2]++;
if(m <= 12 and m > 0 and days[m] >= d and d > 0) {
ret = 1;
}
if(leap) days[2]--;
return ret;
}
void solve(){
int d, m, y;
char tmp;
cin>>d>>tmp>>m>>tmp>>y>>tmp;
for(int i = y; i < 10000; i++) {
int td = (i % 10) * 10 + (i / 10 % 10);
int tm = (i / 100 % 10) * 10 + (i / 1000 % 10);
bool isLarger = 1;
if(i == y) {
if(tm < m) isLarger = 0;
else if(tm == m) {
if(td > d) isLarger = 1;
else isLarger = 0;
}
else {
isLarger = 1;
}
}
if(isLegit(td, tm, !(i % 4)) and isLarger) {
if(td < 10) cout<<0;
cout<<td<<".";
if(tm < 10) cout<<0;
cout<<tm<<".";
if(i < 10) cout<<"000";
else if(i < 100) cout<<"00";
else if(i < 1000) cout<<0;
cout<<i<<".\n";
return;
}
}
}
int32_t main(){
fast
int t=1;
cin>>t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
24 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
24 ms |
348 KB |
Output is correct |