Submission #998977

# Submission time Handle Problem Language Result Execution time Memory
998977 2024-06-15T02:59:10 Z vjudge1 Datum (COCI20_datum) C++17
35 / 50
315 ms 528 KB
#include <bits/stdc++.h>

using namespace std;

map<string,string> mp;

void pr(string s,string t,string y)
{
	cout<<s<<'.'<<t<<'.'<<y<<".\n";
}

pair<string,string> get(string y)
{
	reverse(y.begin(),y.end());
	pair<string,string> p={y.substr(0,2),y.substr(2,2)};
	return p;
}

bool leap(string y)
{
	int y1=stoi(y);
	return y1%4;
}

void add(string &y)
{
	int y1=stoi(y);
	y1++;
	y=to_string(y1);
	while (y.size()<4)
		y='0'+y;
} 

bool valid(pair<string,string> p,string y)
{
	if (p.second>"12" or p.second=="00" or p.first=="00" or !(mp[p.second]>=p.first or (leap(y) && p.first=="29")))
		return false;
	return true;
}

int main()
{
	int t;
	cin>>t;
	int a[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,31};
	for (int i=1;i<=12;i++)
	{
		string wh=to_string(i);
		if (wh.size()<2)
			wh='0'+wh;
		mp[wh]=to_string(a[i-1]);
	}
	while (t--)
	{
		string dd;
		cin>>dd;
		string d=dd.substr(0,2);
		string m=dd.substr(3,2);
		string y=dd.substr(6,4);
		pair<string,string> p=get(y);
		if ((p.second>m or p.first>d) && valid(p,y))
		{
			pr(p.first,p.second,y);
			continue;
		}
		while (1)
		{
			add(y);
			pair<string,string> p=get(y);
			if (valid(p,y))
			{
				pr(p.first,p.second,y);
				break;
			}
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 309 ms 528 KB Output isn't 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 Incorrect 0 ms 348 KB Output isn't correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Incorrect 315 ms 444 KB Output isn't correct