#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define taskname "TITLOVI"
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
struct Ttime{
int h, m, s, ms;
int getNum(const string &s, int l, int r){
int res = 0;
for(int i = l; i <= r; i++){
assert(isdigit(s[i]));
res = res * 10 + s[i] - '0';
}
return res;
}
void init(const string &str){
h = getNum(str, 0, 1);
m = getNum(str, 3, 4);
s = getNum(str, 6, 7);
ms = getNum(str, 9, 11);
}
void shift(int t){
ms += t;
while (ms >= 1000)
ms -= 1000, s++;
while (ms < 0)
ms += 1000, s--;
while (s >= 60)
s -= 60, m++;
while (s < 0)
s += 60, m--;
while (m >= 60)
m -= 60, h++;
while (m < 0)
m += 60, h--;
}
void print(){
printf("%02d:%02d:%02d,%03d", h, m, s, ms);
}
};
struct subtitle{
int ind;
Ttime from, to;
string content;
void shiftTime(int t){
from.shift(t);
to.shift(t);
}
void print(){
cout << ind << endl;
from.print();
cout << " ---> ";
to.print();
cout << content;
}
};
int main(){
string s;
vector <subtitle> subs;
while (s != "#"){
subtitle sub;
cin >> s;
sscanf(s.c_str(), "%d", &sub.ind);
cin >> s;
sub.from.init(s);
cin >> s;
cin >> s;
sub.to.init(s);
getline(cin, s);
s = "*";
while (s != "#" && s != ""){
getline(cin, s);
sub.content.push_back('\n');
sub.content += s;
}
subs.push_back(sub);
}
int t;
cin >> t;
for(subtitle sub : subs){
sub.shiftTime(t);
sub.print();
if (sub.content.back() != '#')
cout << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |