Submission #341496

# Submission time Handle Problem Language Result Execution time Memory
341496 2020-12-29T21:15:37 Z A_D Datum (COCI20_datum) C++14
15 / 50
190 ms 620 KB
/*
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;
}
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';
        }
    }
   // cout<<v<<endl;
    v++;
    while(!ok(v)){
        if(v>9999)return;
        v++;
    }
    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 'void solve()':
datum.cpp:45: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]
   45 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
datum.cpp:71: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]
   71 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
datum.cpp: At global scope:
datum.cpp:79:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   79 | main()
      |      ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Incorrect 190 ms 620 KB Output isn't correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 1 ms 364 KB Output isn't correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Incorrect 182 ms 620 KB Output isn't correct