Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: solarsunny

Problemset: Journey of Love

Language: cpp

Time: 0.003 second

Submitted On: 2025-10-05 14:50:43

#include <bits/stdc++.h>
using namespace std;

int daysInMonth(int y, int m) {
    static int d[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    if (m == 2) {
        bool leap = (y % 400 == 0) || (y % 4 == 0 && y % 100 != 0);
        return leap ? 29 : 28;
    }
    return d[m-1];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long y, mo, d, h, mi, s;
    long long ty, tmo, td, th, tmi, ts;
    cin >> ty >> tmo >> td >> th >> tmi >> ts;

    int n; cin >> n;
    while (n--) {
        long long x; 
        cin >> x;

        y = ty;
        mo = tmo;
        d = td;
        h = th;
        mi = tmi;
        s = ts;

        s += x;
        mi += s / 60;
        s  %= 60;

        h  += mi / 60;
        mi %= 60;

        d  += h / 24;
        h  %= 24;

        while (d > daysInMonth(y, mo)) {
            d -= daysInMonth(y, mo);
            mo++;
            if (mo > 12) {
                mo = 1;
                y++;
            }
        }

        cout << y << " " << mo << " " << d << " " << h << " " << mi << " " << s << "\n";

    }

    return 0;
}