Submission #340392

# Submission time Handle Problem Language Result Execution time Memory
340392 2020-12-27T13:48:14 Z Hazem Datum (COCI20_datum) C++14
40 / 50
1000 ms 492 KB
/*
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

datum.cpp: In function 'bool check(std::string)':
datum.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=0;i<r.size();i++)
      |                 ~^~~~~~~~~
datum.cpp: In function 'int main()':
datum.cpp:68:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 1096 ms 364 KB Time limit exceeded
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 308 ms 364 KB Output is correct
7 Correct 363 ms 364 KB Output is correct
8 Correct 397 ms 364 KB Output is correct
9 Correct 395 ms 364 KB Output is correct
10 Execution timed out 1085 ms 384 KB Time limit exceeded