# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
232457 | kartel | Titlovi (COCI19_titlovi) | C++14 | 5 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define N +2000500
//#define N1 +1001000
//#define M ll(998244353)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
struct str{
string nm;
vector <string> ve;
int h, m, s, t;
int hh, mm, ss, tt;
str (string nm, vector <string> ve, int h, int m, int s, int t, int hh, int mm, int ss, int tt) : nm(nm), ve(ve), h(h), m(m), s(s), t(t), hh(hh), mm(mm), ss(ss), tt(tt) {};
};
vector <str*> v;
int pls, h, m, s, t, kl, hh, mm, ss, tt;
char h1, h2, c, m1, m2, s1, s2, t1, t2, t3;
char hh1, hh2, mm1, mm2, ss1, ss2, tt1, tt2, tt3;
string nm, st;
vector <string> ve;
int main()
{
srand(time(0));
ios_base::sync_with_stdio(0);
iostream::sync_with_stdio(0);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
// in("input.txt");
// out("output.txt");
// getline(cin, st);
getline(cin, st);
while (1)
{
// cerr << st << el;
// cin >> nm;
nm = st;
if (nm == "#") break;
getline(cin, st);
// cin >> h1 >> h2 >> c >> m1 >> m2 >> c >> s1 >> s2 >> c >> t1 >> t2 >> t3 >> c >> c >> c >> c >> c >> hh1 >> hh2 >> c >> mm1 >> mm2 >> c >> ss1 >> ss2 >> c >> tt1 >> tt2 >> tt3;
h1 = st[0]; h2 = st[1]; m1 = st[3]; m2 = st[4]; s1 = st[6]; s2 = st[7]; t1 = st[9]; t2 = st[10]; t3 = st[11];
hh1 = st[17]; hh2 = st[18]; mm1 = st[20]; mm2 = st[21]; ss1 = st[23]; ss2 = st[24]; tt1 = st[26]; tt2 = st[27]; tt3 = st[28];
st = "";
ve.clear();
while (1)
{
getline(cin, st);
if (st[0] == '#') break;
if (st[0] >= '0' && st[0] <= '9') break;
ve.pb(st);
}
// cerr << st << el;
h = 10 * (h1 - '0') + h2 - '0';
m = 10 * (m1 - '0') + m2 - '0';
s = 10 * (s1 - '0') + s2 - '0';
t = 100 * (t1 - '0') + 10 * (t2 - '0') + t3 - '0';
hh = 10 * (hh1 - '0') + hh2 - '0';
mm = 10 * (mm1 - '0') + mm2 - '0';
ss = 10 * (ss1 - '0') + ss2 - '0';
tt = 100 * (tt1 - '0') + 10 * (tt2 - '0') + tt3 - '0';
v.pb(new str(nm, ve, h, m, s, t, hh, mm, ss, tt));
}
cin >> pls;
for (int i = 0; i < sz(v); i++)
{
nm = v[i] -> nm;
ve = v[i] -> ve;
h = v[i] -> h;
m = v[i] -> m;
s = v[i] -> s;
t = v[i] -> t;
hh = v[i] -> hh;
mm = v[i] -> mm;
ss = v[i] -> ss;
tt = v[i] -> tt;
t += pls;
if (pls > 0)
{
if (t > 1000)
{
kl = t / 1000;
t %= 1000;
s += kl;
if (s > 60)
{
kl = s / 60;
s %= 60;
m += kl;
if (m > 60)
{
kl = m / 60;
m %= 60;
h += kl;
}
}
}
tt += pls;
if (tt > 1000)
{
kl = tt / 1000;
tt %= 1000;
ss += kl;
if (ss > 60)
{
kl = ss / 60;
ss %= 60;
mm += kl;
if (mm > 60)
{
kl = mm / 60;
mm %= 60;
hh += kl;
}
}
}
}
else
{
if (t < 0)
{
kl = abs(t / 1000) + 1;
t %= 1000;
t = 1000 + t;
s -= kl;
if (s < 0)
{
kl = abs(s / 60) + 1;
s %= 60;
s = 60 + s;
m -= kl;
if (m < 0)
{
kl = abs(m / 60) + 1;
m %= 60;
m = 60 + m;
h -= kl;
}
}
}
tt += pls;
if (tt < 0)
{
kl = abs(tt / 1000) + 1;
tt %= 1000;
tt = 1000 + tt;
ss -= kl;
if (ss < 0)
{
kl = abs(ss / 60) + 1;
ss %= 60;
ss = 60 + ss;
mm -= kl;
if (mm < 0)
{
kl = abs(mm / 60) + 1;
mm %= 60;
mm = 60 + mm;
hh -= kl;
}
}
}
}
string H = to_string(h);
string M = to_string(m);
string S = to_string(s);
string T = to_string(t);
string HH = to_string(hh);
string MM = to_string(mm);
string SS = to_string(ss);
string TT = to_string(tt);
while (sz(H) != 2) H = "0" + H;
while (sz(M) != 2) M = "0" + M;
while (sz(S) != 2) S = "0" + S;
while (sz(T) != 3) T = "0" + T;
while (sz(HH) != 2) HH = "0" + HH;
while (sz(MM) != 2) MM = "0" + MM;
while (sz(SS) != 2) SS = "0" + SS;
while (sz(TT) != 3) TT = "0" + TT;
cout << nm << el << H << ":" << M << ":" << S << "," << T << " --> " << HH << ":" << MM << ":" << SS << "," << TT << el;
for (auto x : ve) cout << x << el;
}
cout << "#";
}
//3 - 4
//4 - 5
//y < z + x < y + 2 * x
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |