Submission #584251

# Submission time Handle Problem Language Result Execution time Memory
584251 2022-06-27T05:47:33 Z AGE Datum (COCI20_datum) C++14
0 / 50
1000 ms 31700 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++){

        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<1000)
            v.pb(0);

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

        if(year<10)
            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>v;

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

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


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

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

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

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

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

        if(year<10)
            v.pb(0+'0');

        if(year%10000!=0)
            v.pb((year/1000)+'0');

        if(year%1000!=0)
            v.pb((year/100)%10+'0');

        if(year%100!=0)
            v.pb((year/10)%10+'0');

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

        v.pb('.');

    for(int i=0;i<v.size();i++)
        cout<<v[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:21:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int j=s[i].size()-5;j<=s[i].size()-2;j++){
      |                                 ~^~~~~~~~~~~~~~~
datum.cpp:90:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |         for(int i=0;i<v.size()/2;i++)
      |                     ~^~~~~~~~~~~
datum.cpp:141:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  141 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 31572 KB Time limit exceeded
2 Execution timed out 1078 ms 31700 KB Time limit exceeded
3 Execution timed out 1095 ms 31508 KB Time limit exceeded
4 Execution timed out 1089 ms 31528 KB Time limit exceeded
5 Execution timed out 1092 ms 31592 KB Time limit exceeded
6 Execution timed out 1070 ms 31572 KB Time limit exceeded
7 Execution timed out 1088 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 1092 ms 31700 KB Time limit exceeded