Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: anonymous

Problemset: Journey of Love

Language: cpp

Time: 0.004 second

Submitted On: 2026-11-07 20:00:21

#include <bits/stdc++.h>
using namespace std;
bool leap(int y) {
    if (y%400 == 0 || (y%4 == 0 && y%100 != 0)) return 1;
    else return 0;
}
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int Y,M,D,H,Mi,S,q; cin >> Y >> M >> D >> H >> Mi >> S >> q;

    while(q--){
        long long y,m,d,h,mi,s; cin >> s;
        s += S;
        mi = Mi + s/60;
        s %= 60;
        h = H + mi/60;
        mi %= 60;
        d = D + h/24;
        h %= 24;
        y = Y;
        m = M;

        while(1){
            int day = month[m-1];
            if (leap(y) && m == 2) day++;
            if (d <= day) break;
            d -= day;
            m++;
            if (m > 12) m = 1, y++;
        }
        cout << y << ' ' << m << ' ' << d << ' ' << h << ' ' << mi << ' ' << s << '\n';
    }

}