Submission #219309

# Submission time Handle Problem Language Result Execution time Memory
219309 2020-04-05T06:31:46 Z Vimmer Datum (COCI20_datum) C++14
40 / 50
725 ms 632 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define sz(x) ll(x.size())
#define pb push_back
#define N 200005
#define M ll(998244353)

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef short int si;

//typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> oredered_set;


string maker(int x)
{
    string s = to_string(x);

    while (sz(s) < 4) s = '0' + s;

    string st = "";

    st += s[3];

    st += s[2]; st += '.'; st += s[1]; st += s[0]; st += '.';

    st += s;

    st += '.';

    return st;
}

int day, year, month, a[13], r;

bool gd(int x)
{
    string s = maker(x);

    int _month = 10 * (s[3] - '0') + s[4] - '0';

    int _day = 10 * (s[0] - '0') + s[1] - '0';

    return _day > 0 && _month > 0 && (year > r || (_month > month && year == r) || (year == r && month == _month && _day > day)) && _month <= 12 && (_day <= a[month] || (month == 2 && year % 4 == 0 && _day == 29));
}
int main()
{
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    a[1] = 31; a[2] = 28; a[3] = 31; a[4] = 30; a[5] = 31; a[6] = 30; a[7] = 31; a[8] = 31; a[9] = 30; a[10] = 31; a[11] = 30; a[12] = 31;

    int q;

    cin >> q;

    for (; q > 0; q--)
    {
        string s;

        cin >> s;

        year = 1000 * (s[6] - '0') + 100 * (s[7] - '0') + 10 * (s[8] - '0') + s[9] - '0';

        month = 10 * (s[3] - '0') + s[4] - '0';

        day = 10 * (s[0] - '0') + s[1] - '0';

        r = year;

        while (!gd(year)) year++;

        cout << maker(year) << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 694 ms 504 KB Output isn't correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Incorrect 725 ms 632 KB Output isn't correct