Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ayy-2018 Podnapisi C++ 100/100OK 10. maj '18 @ 17:26

Test Točke Porabljen spomin Porabljen čas Status
#1 7/7 3,207 MiB 0,000 s OK
#2 7/7 3,254 MiB 0,000 s OK
#3 7/7 3,168 MiB 0,003 s OK
#4 7/7 3,871 MiB 0,000 s OK
#5 7/7 3,230 MiB 0,003 s OK
#6 7/7 3,156 MiB 0,000 s OK
#7 7/7 3,234 MiB 0,000 s OK
#8 7/7 3,230 MiB 0,003 s OK
#9 7/7 3,238 MiB 0,003 s OK
#10 7/7 3,551 MiB 0,000 s OK
#11 7/7 3,238 MiB 0,003 s OK
#12 7/7 3,277 MiB 0,000 s OK
#13 8/8 3,230 MiB 0,000 s OK
#14 8/8 3,230 MiB 0,000 s OK

Ocenjevani program (podnapisi.cpp):
#include <iostream>
#include <vector>

using namespace std;

int main() {
	string str, shift;
	getline(cin, shift);
	int h, m, s, ms;
	int h1, m1, s1, ms1;
	int h2, m2, s2, ms2;
	
	h = stoi(shift.substr(7, 2));
	m = stoi(shift.substr(10, 2));
	s = stoi(shift.substr(13, 2));
	ms = stoi(shift.substr(16, 3));
	
	vector<string> input;
	input.reserve(10000);
	
	int count = 0;
	
	while (getline(cin, str)) {
		input.push_back(str);
	}
	
	for (int i = 0; i < input.size(); i++) {
		str = input[i];
		if (str == "") {
			count = 0;
			cout << endl;
			continue;
		}
		if (count != 1) {
			if (i == input.size() - 1)
				cout << str;
			else
				cout << str << endl;
		} else {
			// TODO: the magic
			h1 = stoi(str.substr(0, 2));
			m1 = stoi(str.substr(3, 2));
			s1 = stoi(str.substr(6, 2));
			ms1 = stoi(str.substr(9, 3));
			
			h2 = stoi(str.substr(17, 2));
			m2 = stoi(str.substr(20, 2));
			s2 = stoi(str.substr(23, 2));
			ms2 = stoi(str.substr(26, 3));
			
			ms1 += ms;
			if (ms1 > 999) {
				ms1 -= 1000;
				s1++;
			}
			s1 += s;
			if (s1 > 59) {
				s1 -= 60;
				m1++;
			}
			m1 += m;
			if (m1 > 59) {
				m1 -= 60;
				h1++;
			}
			h1 += h;
			
			ms2 += ms;
			if (ms2 > 999) {
				ms2 -= 1000;
				s2++;
			}
			s2 += s;
			if (s2 > 59) {
				s2 -= 60;
				m2++;
			}
			m2 += m;
			if (m2 > 59) {
				m2 -= 60;
				h2++;
			}
			h2 += h;
			
			printf("%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n", h1, m1, s1, ms1, h2, m2, s2, ms2);
		}
		
		count++;
	}
	
	return 0;
}