Submission #846020

# Submission time Handle Problem Language Result Execution time Memory
846020 2023-09-07T06:25:00 Z vjudge1 Datum (COCI20_datum) C++17
0 / 50
83 ms 664 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    #define OPEN freopen(".in", "r", stdin); \
                 freopen(".out", "w", stdout);
#else
    #define OPEN void(23);
#endif

set <int> vec;

int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int toint(string &a)
{
    int val = 0;
    for(char &ch : a) val = val * 10 + (ch - '0');

    return val;
}

void precalc()
{
    for(int i = 1; i <= 12; i++)
    {
        for(int j = 1; j <= months[i]; j++)
        {
            string str = (i <= 9 ? "0" : "") + to_string(i) 
                        + (j <= 9 ? "0" : "") + to_string(j);
            reverse(str.begin(), str.end());
            int year = toint(str);
            vec.emplace(year * 10000 + j * 100 + i);
        }
    }
}

void solve()
{
    string date; cin >> date;
    int day = 0, month = 0, year = 0;
    for(int i = 1; i <= 2; i++) day = day * 10 + date[0 + i -1] - '0';
    for(int i = 1; i <= 2; i++) month = month * 10 + date[3 + i -1] - '0';
    for(int i = 1; i <= 4; i++) year = year * 10 + date[6 + i -1] - '0';

    auto it = vec.upper_bound(year * 10000 + month * 100 + day);
    int _year = *it / 10000;
    int _month = (*it / 100) % 100;
    int _day = *it % 100;

    cerr << day << '.' << month << '.' << year << ".\n";
    if(_day <= 9) cout << '0';
    cout << _day << '.';
    if(_month <= 9) cout << '0';
    cout << _month << '.';
    if(_year <= 9) cout << '0';
    if(_year <= 99) cout << '0';
    if(_year <= 999) cout << '0';
    cout << _year << '.';

    return;
}

int32_t main()
{
    OPEN;

    precalc();

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1; cin >> t;
    while(t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Incorrect 83 ms 664 KB Output isn't correct
3 Incorrect 1 ms 344 KB Output isn't correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Incorrect 1 ms 344 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 1 ms 600 KB Output isn't correct
8 Incorrect 1 ms 344 KB Output isn't correct
9 Incorrect 1 ms 344 KB Output isn't correct
10 Incorrect 79 ms 592 KB Output isn't correct