Submission #845661

# Submission time Handle Problem Language Result Execution time Memory
845661 2023-09-06T14:48:09 Z vjudge1 Datum (COCI20_datum) C++17
50 / 50
18 ms 504 KB
    #include <iostream>
    #include <vector>
    #include <cmath>
    #include <algorithm>
    #include <string>
    #include <map>
    #include <set>
    #include <queue>
    #include <deque>
    using namespace std;
    typedef long long int ll;
    typedef unsigned long long int ull;
    typedef long double ld;
    #define REP(i,a,b) for(ll i=a; i<b; i++)
    #define pb push_back
    #define mp make_pair
    #define pl pair<ll,ll>
    #define ff first
    #define ss second
    #define INF 100000000000000000LL
    ll insig;
    #define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
    void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
     
    string Expand(ll a, ll di)
    {
        string ans="";
        REP(i,0,di)
        {
            ans+=((char) (((ll)('0')) + a%10));
            a/=10;
        }
        reverse(ans.begin(),ans.end());
        return ans;
    }
     
    ll inv(ll x) {ll d1=x/10; ll d2=x%10; return (10*d2+d1);}
     
    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);
        ll T; cin>>T;
        vector<ll> lim; lim.pb(31); lim.pb(29); lim.pb(31); lim.pb(30); lim.pb(31); lim.pb(30); lim.pb(31); lim.pb(31); lim.pb(30); lim.pb(31); lim.pb(30); lim.pb(31);
        vector<ll> a;
        REP(i,0,10000)
        {
            ll m=inv(i/100);
            if(m>12 || m==0) {continue;}
            ll d=inv(i%100);
            if(d==0 || d>lim[m-1]) {continue;}
            if(m==2 && d==29 && i%4!=0) {continue;}
            a.pb(d+100*m+10000*i);
        }
        REP(t,0,T)
        {
            string s; cin>>s; 
            vector<ll> digits;
            REP(i,0,s.size()) 
            {
                if(s[i]=='.') {continue;}
                digits.pb((ll) (s[i]-'0'));
            }
            ll y=1000*digits[4]+100*digits[5]+10*digits[6]+digits[7];
            ll m=10*digits[2]+digits[3];
            ll d=10*digits[0]+digits[1];
            ll v=10000*y+100*m+d;
            ll ans=*upper_bound(a.begin(),a.end(),v);
            d=ans%100; ans/=100; m=ans%100; ans/=100; y=ans;
            cout<<Expand(d,2)<<"."<<Expand(m,2)<<"."<<Expand(y,4)<<"."<<endl;
        }
        return 0;
    }

Compilation message

datum.cpp: In function 'void Out(std::vector<long long int>)':
datum.cpp:14:37: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     #define REP(i,a,b) for(ll i=a; i<b; i++)
......
   23 |     void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
      |                                 ~~~~~~~~~~~~
datum.cpp:23:29: note: in expansion of macro 'REP'
   23 |     void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
      |                             ^~~
datum.cpp: In function 'int main()':
datum.cpp:14:37: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     #define REP(i,a,b) for(ll i=a; i<b; i++)
......
   59 |             REP(i,0,s.size())
      |                 ~~~~~~~~~~~~         
datum.cpp:59:13: note: in expansion of macro 'REP'
   59 |             REP(i,0,s.size())
      |             ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 15 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 18 ms 488 KB Output is correct