# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340392 | Hazem | Datum (COCI20_datum) | C++14 | 1096 ms | 492 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/
#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
const int N = 4e2 + 10;
LL LINF = 100000000000000000;
LL INF = 1000000000;
int MOD = 1e9+7;
int days[] ={31,28,31,30,31,30,31,31,30,31,30,31};
string get_nxt(string s){
int d = (s[0]-'0')*10+(s[1]-'0'), m = (s[3]-'0')*10+(s[4]-'0');
int y = 0;
for(int i=6;i<=9;i++)
y = y*10+(s[i]-'0');
if(d==days[m-1]+(m==2&&y%4==0)){
d = 1;
if(m==12)y++,m = 1;
else m++;
}
else d++;
string ret = "";
ret += ('0'+(d/10));
ret += ('0'+(d%10));
ret += ('0'+(m/10));
ret += ('0'+(m%10));
for(int i=3;i>=0;i--)
ret += '0'+(y%10),y /= 10;
reverse(ret.begin()+4,ret.end());
return ret;
}
bool check(string s){
string r = "";
for(char c:s)
if(c>='0'&&c<='9')r += c;
bool q = 1;
for(int i=0;i<r.size();i++)
q &= r[i]==r[r.size()-i-1];
return q;
}
int main()
{
//freopen("out.txt","w",stdout);
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
string s;
cin>>s;
while(1){
string r = get_nxt(s);
s = "";
for(int i=0;i<2;i++)
s += r[i];
s+= '.';
for(int i=2;i<4;i++)
s += r[i];
s += '.';
for(int i=4;i<=7;i++)
s += r[i];
s+='.';
if(check(r))break;
}
cout<<s<<endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |