/*
ID: antwand1
TASK: pprime
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define du long double
#define F first
#define S second
#define FOR(a,b) for(int a=1;a<=b;a++)
#define FORl(a,b) for(a=1;a<=b;a++)
#define FOR0(a,b) for(int a=1;a<b;a++)
#define FORl0(a,b) for(a=0;a<b;a++)
#define ii pair<int,int>
using namespace std;
int a[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool ok(int v)
{
if(v%4==0)a[1]=29;
else a[1]=28;
string s;
while(v){
s+=(v%10)+'0';
v/=10;
}
while(s.size()<4){
s+='0';
}
// cout<<s<<" ";
int q=(s[2]-'0')*10+s[3]-'0';
// cout<<q<<" ";
int g=(s[0]-'0')*10+s[1]-'0';
//cout<<g<<endl;
if(q==0||q>12)return 0;
return g&&a[q]>=g;
}
bool k(string a,string b)
{
int q1=(a[3]-'0')*10+a[4]-'0';
int g1=(a[0]-'0')*10+a[1]-'0';
int q2=(b[3]-'0')*10+b[4]-'0';
int g2=(b[0]-'0')*10+b[1]-'0';
if(q1>q2)return 1;
return g1>g2&&q1==q2;
}
void solve()
{
string S;
int cnt=0;
cin>>S;
int v=0;
for(int i=0;i<S.size();i++){
if(S[i]=='.'){
cnt++;
continue;
}
if(cnt==2){
v*=10;
v+=S[i]-'0';
}
}
// cout<<v<<endl;
//v++;
int h=v;
if(ok(v)){
string s="";
while(v){
s+=(v%10)+'0';
v/=10;
}
while(s.size()<4)s=s+'0';
string f=s;
reverse(f.begin(),f.end());
s+=f;
string ans;
for(int i=0;i<s.size();i++){
ans+=s[i];
if(i==1)ans+='.';
if(i==3)ans+='.';
}
//cout<<ans<<endl;
ans+='.';
if(k(ans,S)){
cout<<ans<<endl;
return;
}
}
v=h;
v++;
while(!ok(v)){
if(v>9999)assert(0);
v++;
}
string s="";
while(v){
s+=(v%10)+'0';
v/=10;
}
while(s.size()<4)s=s+'0';
string f=s;
reverse(f.begin(),f.end());
s+=f;
string ans;
for(int i=0;i<s.size();i++){
ans+=s[i];
if(i==1)ans+='.';
if(i==3)ans+='.';
}
ans+='.';
cout<<ans<<endl;
}
main()
{
int n;
cin>>n;
while(n--)solve();
}
Compilation message
datum.cpp: In function 'void solve()':
datum.cpp:54:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i=0;i<S.size();i++){
| ~^~~~~~~~~
datum.cpp:78:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
datum.cpp:106:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
106 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
datum.cpp: At global scope:
datum.cpp:114:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
114 | main()
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
180 ms |
492 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
10 |
Incorrect |
202 ms |
596 KB |
Output isn't correct |