Submission #845400

# Submission time Handle Problem Language Result Execution time Memory
845400 2023-09-06T13:29:06 Z vjudge1 Datum (COCI20_datum) C++17
50 / 50
7 ms 604 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long
#define pb push_back
#define lim 300000
#define till 40001
// # of primes till 1e6 = 7e4
using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
using pii = array<int,2>;

const int mod=1000000007ll;

set<string>valid;

int monthd[12]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

bool valider(string s){
    int month=(s[1]-'0')*10+(s[0]-'0');
    if(12<month)return 0;
    int day=(s[3]-'0')*10+(s[2]-'0');
    if(!day)return 0;
    if(day<=monthd[month-1]||(month==2&&day==29)){
        return 1;
    }
    return 0;
}

void solve(){
    string s;
    cin>>s;
    string date=s.substr(6,4);
    auto ite=valid.lower_bound(date);
    if(*ite!=date){
        cout<<(*ite)[3]<<(*ite)[2]<<"."<<(*ite)[1]<<(*ite)[0]<<"."<<*ite<<".\n";
    }else{
        cerr<<*ite<<" "<<s[0]<<s[1]<<s[3]<<s[4]<<"\n";
        if((*ite)[1]<s[3])ite++;
        else if((*ite)[1]==s[3]){
            if((*ite)[0]<s[4]){
                ite++;
            }
            else if((*ite)[0]==s[4]){
                if((*ite)[3]<s[0]){
                    ite++;
                }
                else if((*ite)[3]==s[0]){
                    if((*ite)[2]<=s[1]){
                        ite++;
                    }
                }
            }
        }
        cout<<(*ite)[3]<<(*ite)[2]<<"."<<(*ite)[1]<<(*ite)[0]<<"."<<*ite<<".\n";
    }
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
#ifndef INTERACTIVE
    freopen("in","r",stdin);
#endif
    freopen("out","w",stdout);
#endif
    int t=1;
    cin>>t;
    string s="0000";
    for(;s[0]<='9';s[0]++){
        s[1]='0';
        for(;s[1]<='9';s[1]++){
            s[2]='0';
            for(;s[2]<='9';s[2]++){
                s[3]='0';
                for(;s[3]<='9';s[3]++){
                    if(valider(s)){
                        valid.insert(s);
                    }//cerr<<s<<"\n";
                }
            }
        }
    }
    while (t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 7 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 7 ms 484 KB Output is correct