#include <bits/stdc++.h>
using namespace std;
#define mod 1'000'000'007
typedef long long ll;
template <typename T>
void deb(initializer_list<T> l)
{
for (auto &e : l)
cout << e << ' ';
cout << '\n';
}
#define time ttime
ll toNum(string s)
{
ll num = 0;
for (auto &c : s)
num = num * 10 + (ll) (c - '0');
return num;
}
ll toNum(char c)
{
return (ll) (c - '0');
}
void change(string str, ll &h, ll &m, ll &s, ll &t)
{
h = toNum(str[0]) * 10 + toNum(str[1]);
m = toNum(str[3]) * 10 + toNum(str[4]);
s = toNum(str[6]) * 10 + toNum(str[7]);
t = toNum(str[9]) * 100 + toNum(str[10]) * 10 + toNum(str[11]);
}
void convert(string s1, vector<ll> &h, vector<ll> &m, vector<ll> &s, vector<ll> &t)
{
string str = "00:00:01,600";
ll len = str.length();
ll a, b, c, d;
change(s1.substr(0, len), a, b, c, d);
h.push_back(a);
m.push_back(b);
s.push_back(c);
t.push_back(d);
str = " --> ";
len += str.length();
change(s1.substr(len), a, b, c, d);
h.push_back(a);
m.push_back(b);
s.push_back(c);
t.push_back(d);
// string str = 00:00:01,600 --> 00:00:04,200
// 0123456789
}
void print(ll x)
{
if (x < 10)
cout << 0;
cout << x;
}
void solve()
{
vector<ll> o;
vector<vector<ll>> hh, mm, ss, ttt;
vector<vector<string>> s;
vector<string> s2;
bool read = 0, flag = 0;
ll t;
while (true)
{
if (flag)
break;
string str;
getline(cin, str);
// if (str == "")
// cout << 1/0;
if (str == "#")
{
cin >> t;
break;
}
if (read)
{
read = 0;
// getline(cin, str);
// if (str == "")
// cout << 1/0;
vector<ll> h, m, sec, tt;
convert(str, h, m, sec, tt);
hh.push_back(h);
mm.push_back(m);
ss.push_back(sec);
ttt.push_back(tt);
}
else
{
o.push_back(toNum(str));
getline(cin, str);
// if (str == "")
// cout << 1/0;
vector<ll> h, m, sec, tt;
convert(str, h, m, sec, tt);
hh.push_back(h);
mm.push_back(m);
ss.push_back(sec);
ttt.push_back(tt);
}
s2.clear();
while (true)
{
getline(cin, str);
if (str == "")
continue;
if (str[0] == '#')
{
flag = 1;
cin >> t;
break;
}
if (isdigit(str[0]))
{
read = 1;
o.push_back(toNum(str));
break;
}
s2.push_back(str);
}
s.push_back(s2);
}
ll h, m, sec, ms;
ms = abs(t) % 1000;
sec = abs(t) / 1000;
for (ll i = 0; i < o.size(); ++i)
{
cout << o[i] << '\n';
if (t > 0)
{
ll temp = sec + (ttt[i][0] + ms) / 1000;
ttt[i][0] = (ttt[i][0] + ms) % 1000;
ll temp2 = (ss[i][0] + temp) / 60;
ss[i][0] = (ss[i][0] + temp) % 60;
temp = (mm[i][0] + temp2) / 60;
mm[i][0] = (mm[i][0] + temp2) % 60;
hh[i][0] = hh[i][0] + temp;
temp = sec + (ttt[i][1] + ms) / 1000;
ttt[i][1] = (ttt[i][1] + ms) % 1000;
temp2 = (ss[i][1] + temp) / 60;
ss[i][1] = (ss[i][1] + temp) % 60;
temp = (mm[i][1] + temp2) / 60;
mm[i][1] = (mm[i][1] + temp2) % 60;
hh[i][1] = hh[i][1] + temp;
}
else if (t < 0)
{
ttt[i][0] = ttt[i][0] - ms;
if (ttt[i][0] < 0)
{
ttt[i][0] += 1000;
--ss[i][0];
}
ss[i][0] = ss[i][0] - sec;
if (ss[i][0] < 0)
{
ss[i][0] += 60;
--mm[i][0];
}
if (mm[i][0] < 0)
{
mm[i][0] += 60;
--hh[i][0];
}
ttt[i][1] = ttt[i][1] - ms;
if (ttt[i][1] < 0)
{
ttt[i][1] += 1000;
--ss[i][1];
}
ss[i][1] = ss[i][1] - sec;
if (ss[i][1] < 0)
{
ss[i][1] += 60;
--mm[i][1];
}
if (mm[i][1] < 0)
{
mm[i][1] += 60;
--hh[i][1];
}
}
// 00:00:01,600 --> 00:00:04,200
print(hh[i][0]);
cout << ':';
print(mm[i][0]);
cout << ':';
print(ss[i][0]);
cout << ',';
if (ttt[i][0] < 100)
cout << '0';
if (ttt[i][0] < 10)
cout << '0';
cout << ttt[i][0] << " --> ";
print(hh[i][1]);
cout << ':';
print(mm[i][1]);
cout << ':';
print(ss[i][1]);
cout << ',';
if (ttt[i][1] < 100)
cout << '0';
if (ttt[i][1] < 10)
cout << '0';
cout << ttt[i][1] << '\n';
for (auto &str : s[i])
cout << str << '\n';
if (i == o.size() - 1)
break;
cout << '\n';
}
cout << '#';
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t { 1 };
//cin >> t;
while (t--)
solve();
return 0;
}
Compilation message
titlovi.cpp: In function 'void solve()':
titlovi.cpp:138:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (ll i = 0; i < o.size(); ++i)
~~^~~~~~~~~~
titlovi.cpp:222:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (i == o.size() - 1)
~~^~~~~~~~~~~~~~~
titlovi.cpp:135:8: warning: unused variable 'h' [-Wunused-variable]
ll h, m, sec, ms;
^
titlovi.cpp:135:11: warning: unused variable 'm' [-Wunused-variable]
ll h, m, sec, ms;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |