Submission #584254

# Submission time Handle Problem Language Result Execution time Memory
584254 2022-06-27T05:56:33 Z AGE Datum (COCI20_datum) C++14
0 / 50
1000 ms 31572 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
using namespace std;
const int N=1e6,M=1502,mod=1e9+7,p=31;
int year,month,day;
int a[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s[N];
main()
{
    int n;
    cin>>n;

    for(int i=0;i<n;i++)
        cin>>s[i];

    for(int i=0;i<n;i++){
        year=0,day=0,month=0;

        for(int j=s[i].size()-5;j<=s[i].size()-2;j++){
            year+=(s[i][j]-'0');
            year*=10;
        }
        year/=10;

        month=s[i][s[i].size()-8]-'0';
        month*=10;
        month+=(s[i][s[i].size()-7])-'0';

        day=s[i][0]-'0';
        day*=10;
        day+=(s[i][1]-'0');


    while(1){


        vector<int>v;
        int x=a[month];
        if(month==2&&year%4==0)
            x--;

        day++;
        if(day>x)
            day=1,month++;

        if(month>12)
            month=1,year++;

        if(day<10)
            v.pb(0);

        if(day>=10)
            v.pb(day/10);


        v.pb(day%10);

        if(month<10)
            v.pb(0);

        if(month>=10)
            v.pb((month/10));
        v.pb(month%10);

        if(year<10000)
            v.pb(0);

        if(year<1000)
            v.pb(0);

        if(year<100)
            v.pb(0);

        if(year>=1000)
            v.pb((year/1000));

        if(year>=100)
            v.pb((year/100)%10);

        if(year>=10)
            v.pb((year/10)%10);

        v.pb(year%10);

        int ok=0;
        for(int i=0;i<v.size()/2;i++)
            if(v[i]!=v[v.size()-1-i])
                ok=1;

        if(ok==0)
            break;
    }

        vector<char>vv;

        if(day<10)
            vv.pb('0');

        if(day>=10)
            vv.pb(day/10+'0');


        vv.pb(day%10+'0');

        vv.pb('.');
        if(month<10)
            vv.pb(0+'0');

        if(month%10==0)
            vv.pb((month/10)+'0');
        vv.pb(month%10+'0');

        vv.pb('.');
        if(year<1000)
            vv.pb(0+'0');

        if(year<100)
            vv.pb(0+'0');

        if(year>=1000)
            vv.pb((year/1000)+'0');

        if(year>=100)
            vv.pb((year/100)%10+'0');

        if(year>=10)
            vv.pb((year/10)%10+'0');

        vv.pb(year%10+'0');

        vv.pb('.');

    for(int i=0;i<vv.size();i++)
        cout<<vv[i];
    cout<<endl;

    }
    return 0;
}

Compilation message

datum.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main()
      | ^~~~
datum.cpp: In function 'int main()':
datum.cpp:22:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int j=s[i].size()-5;j<=s[i].size()-2;j++){
      |                                 ~^~~~~~~~~~~~~~~
datum.cpp:89:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |         for(int i=0;i<v.size()/2;i++)
      |                     ~^~~~~~~~~~~
datum.cpp:136:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  136 |     for(int i=0;i<vv.size();i++)
      |                 ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 31572 KB Output isn't correct
2 Execution timed out 1077 ms 31572 KB Time limit exceeded
3 Execution timed out 1088 ms 31572 KB Time limit exceeded
4 Incorrect 16 ms 31572 KB Output isn't correct
5 Incorrect 16 ms 31540 KB Output isn't correct
6 Execution timed out 1094 ms 31504 KB Time limit exceeded
7 Execution timed out 1089 ms 31572 KB Time limit exceeded
8 Execution timed out 1085 ms 31572 KB Time limit exceeded
9 Execution timed out 1091 ms 31572 KB Time limit exceeded
10 Execution timed out 1093 ms 31572 KB Time limit exceeded