#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
typedef long long llint;
const int MOD = 1e9 + 7;
struct SRT {
int block_id;
int t_start, t_end;
vector<string> text;
};
int n, dt;
vector<SRT> v;
ostream &operator<<(ostream &o, const SRT &srt) {
o << srt.block_id << endl;
int start = srt.t_start, end = srt.t_end;
int start_ms, start_s, start_m, start_h;
start_ms = start % 1000; start -= start_ms; start /= 1000;
start_s = start % 60; start -= start_s; start /= 60;
start_m = start % 60; start -= start_m; start /= 60;
start_h = start;
int end_ms, end_s, end_m, end_h;
end_ms = end % 1000; end -= end_ms; end /= 1000;
end_s = end % 60; end -= end_s; end /= 60;
end_m = end % 60; end -= end_m; end /= 60;
end_h = end;
o << setfill('0') << setw(2) << start_h << ":" <<
setfill('0') << setw(2) << start_m << ":" <<
setfill('0') << setw(2) << start_s << "," <<
setfill('0') << setw(3) << start_ms << " --> ";
o << setfill('0') << setw(2) << end_h << ":" <<
setfill('0') << setw(2) << end_m << ":" <<
setfill('0') << setw(2) << end_s << "," <<
setfill('0') << setw(3) << end_ms << endl;
for (const string &s : srt.text) o << s << endl;
return o;
}
SRT parse_srt() {
int block_id, t_start, t_end;
int start_h, start_m, start_s, start_ms;
int end_h, end_m, end_s, end_ms;
vector<string> text;
cin >> block_id;
cin >> start_h; cin.ignore();
cin >> start_m; cin.ignore();
cin >> start_s; cin.ignore();
cin >> start_ms; string dummy; cin >> dummy;
cin >> end_h; cin.ignore();
cin >> end_m; cin.ignore();
cin >> end_s; cin.ignore();
cin >> end_ms; cin.ignore(5, '\n');
t_start = start_ms + start_s * 1000 + start_m * 1000 * 60 + start_h * 1000 * 60 * 60;
t_end = end_ms + end_s * 1000 + end_m * 1000 * 60 + end_h * 1000 * 60 * 60;
string line;
do {
getline(cin, line);
text.push_back(line);
} while (line.size() > 0 && line != "#");
return { block_id, t_start, t_end, text };
}
int main(void) {
while (true) {
auto srt = parse_srt();
v.push_back(srt);
if (srt.text[srt.text.size() - 1] == "#") break;
}
cin >> dt;
for (auto &srt : v) {
srt.t_start += dt;
srt.t_end += dt;
}
for (auto &srt : v)
cout << srt;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 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 |
296 KB |
Output is correct |