Submission #845307

# Submission time Handle Problem Language Result Execution time Memory
845307 2023-09-06T13:06:57 Z vjudge1 Datum (COCI20_datum) C++17
25 / 50
227 ms 612 KB
#include <bits/stdc++.h>
using namespace std;
bool check(string _year){
	int day = (_year[3]-'0')*10+(_year[2]-'0');
	int month = (_year[1]-'0')*10+(_year[0]-'0');
	int year = _year[0]*1000+_year[1]*100+_year[2]*10+_year[3];
	if (month<=0 || month>=13) return false;
	int ma = 31;
	if (month==4) ma = 30;
	if (month==6) ma = 30;
	if (month==9) ma = 30;
	if (month==11) ma = 30;
	if (month==2){
		ma=28;
		if (year%4==0) ma=29;
	}
	if (day<=0 || day>ma) return false;
	return true;
}
string make(int num){
	string year = to_string(num);
	string ret = "";
	ret.push_back(year[3]);
	ret.push_back(year[2]);
	ret.push_back('.');
	ret.push_back(year[1]);
	ret.push_back(year[0]);
	ret.push_back('.');
	ret.push_back(year[0]);
	ret.push_back(year[1]);
	ret.push_back(year[2]);
	ret.push_back(year[3]);
	ret.push_back('.');
	return ret;
}
string getmonth(string date){
	return date.substr(3,2);
}
string getyear(string date){
	return date.substr(6,4);
}
string getday(string date){
	return date.substr(0,2);
}
int32_t main(){
	int n;cin>>n;
	while (n--){
		string str;cin>>str;
		int cry = (str[6]-'0')*1000+(str[7]-'0')*100+(str[8]-'0')*10+(str[9]-'0');
		string hehe = make(cry);
		while (!check(to_string(cry)) || getyear(hehe)<getyear(str) || (getyear(hehe)==getyear(str) && getmonth(hehe)<getmonth(str)) || (getyear(hehe)==getyear(str) && getmonth(hehe)==getmonth(str) && getday(hehe)<=getday(str))){
			cry++;
			hehe=make(cry);
		}
		cout<<make(cry)<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 219 ms 612 KB Output isn't correct
3 Incorrect 0 ms 344 KB Output isn't correct
4 Incorrect 1 ms 600 KB Output isn't correct
5 Incorrect 0 ms 344 KB Output isn't correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Incorrect 227 ms 348 KB Output isn't correct