Submission #624371

# Submission time Handle Problem Language Result Execution time Memory
624371 2022-08-08T04:52:41 Z nguyen31hoang08minh2003 Datum (COCI20_datum) C++14
50 / 50
20 ms 596 KB
#include <bits/stdc++.h>
#define fore(i, a, b) for (int i = (a), i##_last = (b); i < i##_last; ++i)
#define fort(i, a, b) for (int i = (a), i##_last = (b); i <= i##_last; ++i)
#define ford(i, a, b) for (int i = (a), i##_last = (b); i >= i##_last; --i)
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using ld = long double;

template<class A, class B> bool maxi(A &a, const B &b) {return (a < b) ? (a = b, true):false;};
template<class A, class B> bool mini(A &a, const B &b) {return (a > b) ? (a = b, true):false;};

typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const short days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int n;

int getReversedNumber(int n) {
    int res = 0;
    for (; n; n /= 10)
        (res *= 10) += n % 10;
    return res;
}

string getReverseString(string s) {
    reverse(all(s));
    return s;
}

int convertStringToInt(const string &s) {
    int res;
    stringstream ss(s);
    ss >> res;
    return res;
}

string convertIntToString(int n) {
    stringstream ss;
    ss << n;
    return ss.str();
}

int main() {
    vi date(3);
    int year;
    vvi dates;
    string s;
    #ifdef LOCAL
        freopen("input.INP", "r", stdin);
//        freopen("output.OUT", "w", stdout);
    #endif // LOCAL
    cin.tie(0) -> sync_with_stdio(0);
    cout.tie(0);
    fort(month, 1, 12)
        fort(day, 1, days[month - 1]) {
            stringstream y;
            y << setw(2) << setfill('0') << day << setw(2) << setfill('0') << month;
            year = convertStringToInt(getReverseString(y.str()));
            if (year % 4 && month == 2 && day == 29)
                continue;
            dates.pb({year, month, day});
        }
    sort(all(dates));
//    for (const auto &date : dates) {
//        for (const auto &x : date)
//            cerr << x << ' ';
//        cerr << '\n';
//    }
    cin >> n;
    cin.ignore(100, '\n');
    fort(_, 1, n) {
        date.clear();
        fort(i, 0, 2) {
            getline(cin, s, '.');
            stringstream ss(s);
            date.pb(0);
            ss >> date.back();
        }
        reverse(all(date));
//        cerr << date[0] << ' ' << date[1] << ' ' << date[2] << '\n';
        date = *upper_bound(all(dates), date);
        cout << setw(2) << setfill('0') << date.back() << '.' << setw(2) << setfill('0') << date[1] << '.' << setw(4) << setfill('0') << date.front() << ".\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 20 ms 464 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 20 ms 596 KB Output is correct