제출 #845069

#제출 시각아이디문제언어결과실행 시간메모리
845069vjudge1Datum (COCI20_datum)C++17
50 / 50
24 ms348 KiB
#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();
}
#Verdict Execution timeMemoryGrader output
Fetching results...