답안 #845369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
845369 2023-09-06T13:22:00 Z vjudge1 Datum (COCI20_datum) C++17
0 / 50
1000 ms 448 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define all(c) (c).begin(), (c).end()

bool f(string ck){
	int n = ck.size(),ok = 1;
	for(int i = 0; i < n; i++){
		if(ck[i] != ck[n - i - 1]){
			return false;
		}
	}
	return true;
}

void solve(){	

	string s;
	cin >> s;

	while(37){
		int d,m,y;
		d = (s[0] - '0') * 10 + s[1] - '0';
		m = (s[3] - '0') * 10 + s[4] - '0';
		y = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + s[9] - '0';

		while(y / 10 % 10 > 3) y += 10;
		while(y % 10 > 3) y++;

		if(m == 2){
			if(y % 4 == 0){
				if(d == 29){
					d = 1;
					m++;
				}
				else d++;
			}
			else{
				if(d == 28){
					d = 1;
					m++;
				}
				else d++;
			}	
		}
		else{
			if((m % 2 && m <= 7) || (m % 2 == 0 && m > 7)){
				if(d == 31){
					d = 1;
					if(m == 12){
						m = 1;
						y++;
					}
					else m++;
				}
				else d++;
			}
			else{
				if(d == 30){
					d = 1;
					if(m == 12){
						m = 1;
						y++;
					}
					else m++;
				}
				else d++;	
			}
		}


		string dd;
		if(d < 10) dd = '0' + to_string(d);
		else dd = to_string(d);

		string mm;
		if(m < 10) mm = '0' + to_string(m);
		else mm = to_string(m);

		string yy;
		if(y < 10) yy = string("0",3) + to_string(y);
		else if(y < 100) yy = string("0",2) + to_string(y);
		else if(y < 1000) yy = string("0",1) + to_string(y);
		else yy = to_string(y);

		string ck = dd + mm + yy;
		string fuck = ck.substr(0,2) + '.' + ck.substr(2,2) + '.' + ck.substr(4,4) + '.';
		if(f(ck)){
			cout << fuck << endl;
			return;
		}
		s = fuck;
	}
}

signed main(){

	cin.tie(0);
	ios_base::sync_with_stdio(0);

	#ifndef ONLINE_JUDGE
//		freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
	#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;
	cin >> t;

	while(t--){
		solve();
	}

	return 0;
}

Compilation message

datum.cpp: In function 'bool f(std::string)':
datum.cpp:8:20: warning: unused variable 'ok' [-Wunused-variable]
    8 |  int n = ck.size(),ok = 1;
      |                    ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 448 KB Output isn't correct
2 Execution timed out 1056 ms 348 KB Time limit exceeded
3 Incorrect 28 ms 348 KB Output isn't correct
4 Incorrect 39 ms 344 KB Output isn't correct
5 Incorrect 50 ms 344 KB Output isn't correct
6 Incorrect 34 ms 448 KB Output isn't correct
7 Incorrect 64 ms 348 KB Output isn't correct
8 Incorrect 47 ms 344 KB Output isn't correct
9 Incorrect 38 ms 348 KB Output isn't correct
10 Execution timed out 1065 ms 428 KB Time limit exceeded