/*
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(int v,string S)
{
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+='.';
int q1=(ans[3]-'0')*10+ans[4]-'0';
int g1=(ans[0]-'0')*10+ans[1]-'0';
int q2=(S[3]-'0')*10+S[4]-'0';
int g2=(S[0]-'0')*10+S[1]-'0';
if((q1>q2)||(g1>g2&&q1==q2)){
cout<<ans<<endl;
return 1;
}
return 0;
}
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';
}
}
if(ok(v)&&k(v,S)){
return;
}
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 'bool k(long long int, std::string)':
datum.cpp:51: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]
51 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
datum.cpp: In function 'void solve()':
datum.cpp:73: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]
73 | for(int i=0;i<S.size();i++){
| ~^~~~~~~~~
datum.cpp:101: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]
101 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
datum.cpp: At global scope:
datum.cpp:110:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
110 | main()
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
179 ms |
452 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 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 |
181 ms |
492 KB |
Output isn't correct |