Submission #232474

#TimeUsernameProblemLanguageResultExecution timeMemory
232474VimmerTitlovi (COCI19_titlovi)C++14
50 / 50
5 ms384 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 100005 #define MOD ll(1e9 + 7) #define block 500 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_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; vector <int> h, m, st, t, x, nh, nm, ns, nt; vector <vector <string> > g; void make(int &H, int &M, int &S, int &T, int dob) { if (dob > 0) { int kl = dob / 1000; if (T + (dob % 1000) >= 1000) kl++; T = (T + (dob % 1000)) % 1000; if (S + kl < 60) S += kl; else { S = (S + kl) % 60; if (M + 1 < 60) M++; else { M = 0; H++; } } } else { dob = - dob; if (dob <= T) {T -= dob; return;} dob -= T; bool f = 0; T = 0; if (dob % 1000 != 0) { T = (1000 - (dob % 1000)); f = 1; } dob /= 1000; if (f) dob++; if (dob <= S) {S -= dob; return;} dob -= S; S = 0; f = 0; if (dob % 60 != 0) { S = (60 - (dob % 60)); f = 1; } dob /= 60; if (f) dob++; if (dob <= M) {M -= dob; return;} dob -= M; M = 0; f = 0; if (dob % 60 != 0) { M = (60 - (dob % 60)); f = 1; } dob /= 60; if (f) dob++; H += dob; } } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s = ""; while (s != "#") { getline(cin, s); int X = 0; int j = 1; for (int i = sz(s) - 1; i >= 0; i--) { X += (s[i] - '0') * j; j *= 10; } x.pb(X); getline(cin, s); int H = (s[0] - '0') * 10 + (s[1] - '0'); int M = (s[3] - '0') * 10 + (s[4] - '0'); int S = (s[6] - '0') * 10 + (s[7] - '0'); int T = (s[9] - '0') * 100 + (s[10] - '0') * 10 + (s[11] - '0'); h.pb(H); m.pb(M); st.pb(S); t.pb(T); H = (s[17] - '0') * 10 + (s[18] - '0'); M = (s[20] - '0') * 10 + (s[21] - '0'); S = (s[23] - '0') * 10 + (s[24] - '0'); T = (s[26] - '0') * 100 + (s[27] - '0') * 10 + (s[28] - '0'); nh.pb(H); nm.pb(M); ns.pb(S); nt.pb(T); g.emplace_back(); getline(cin, s); while (s != " " && s != "#" && s != "") { g.back().pb(s); getline(cin, s); } } int dob; cin >> dob; for (int i = 0; i < sz(x); i++) { if (i != 0) cout << endl; cout << x[i] << endl; int H = h[i], M = m[i], S = st[i], T = t[i]; make(H, M, S, T, dob); if (H > 9) cout << H << ":"; else cout << "0" << H << ":"; if (M > 9) cout << M << ":"; else cout << "0" << M << ":"; if (S > 9) cout << S << ","; else cout << "0" << S << ","; if (T > 99) cout << T; else { cout << '0'; if (T > 9) cout << T; else cout << "0" << T; } cout << " --> "; H = nh[i]; M = nm[i]; S = ns[i]; T = nt[i]; make(H, M, S, T, dob); if (H > 9) cout << H << ":"; else cout << "0" << H << ":"; if (M > 9) cout << M << ":"; else cout << "0" << M << ":"; if (S > 9) cout << S << ","; else cout << "0" << S << ","; if (T > 99) cout << T; else { cout << '0'; if (T > 9) cout << T; else cout << "0" << T; } cout << endl; for (auto it : g[i]) cout << it << endl; } cout << "#"; }
#Verdict Execution timeMemoryGrader output
Fetching results...