Submission #96626

# Submission time Handle Problem Language Result Execution time Memory
96626 2019-02-10T13:42:47 Z tnbs10 Titlovi (COCI19_titlovi) Python 3
20 / 50
33 ms 3560 KB
s = ' '
titlovi = []
whatis = []   # 1 - broj, 2 - vrijeme, 3 - titl
while s != '#':
    titlovi.append(input())
    whatis.append(1)
    titlovi.append(input())
    whatis.append(2)
    s = input()
    while s and s != '#':
        titlovi.append(s)
        whatis.append(3)
        s = input()
#print(titlovi)
#print(whatis)
mili = int(input())
for i in range(len(titlovi)):
    if whatis[i] == 2:
        h1 = int(titlovi[i][0:2])
        m1 = int(titlovi[i][3:5])
        s1 = int(titlovi[i][6:8])
        ms1 = int(titlovi[i][9:12])
        h2 = int(titlovi[i][17:19])
        m2 = int(titlovi[i][20:22])
        s2 = int(titlovi[i][23:25])
        ms2 = int(titlovi[i][26:29])
        #print(h1, m1, s1, ms1, "-->", h2, m2, s2, ms2)
        ms1 += mili
        flag = False
        
        if mili > 0:
            flag = True
        if ms1 > 999 and flag:
            ms1 %= 1000
            s1 += 1
        if s1 > 59 and flag:
            s1 %= 60
            m1 += 1
        if m1 > 59 and flag:
            m1 %= 60
            h1 += 1
        ms2 += mili
        if ms2 > 999 and flag:
            ms2 %= 1000
            s2 += 1
        if s2 > 59 and flag:
            s2 %= 60
            m2 += 1
        if m2 > 59 and flag:
            m2 %= 60
            h2 += 1
    
        if mili < 0:
            flag = True
            
        if ms1 < 0 and flag:
            ms1 += 1000
            s1 -= 1
        if s1 < 0 and flag:
            s1 += 60
            m1 -= 1
        if m1 < 0 and flag:
            m1 += 60
            h1 -= 1
            
        if ms2 < 0 and flag:
            ms2 += 1000
            s2 -= 1
        if s2 < 0 and flag:
            s2 += 60
            m2 -= 1
        if m2 <0 and flag:
            m2 += 60
            h2 -= 1
            
       
        #print(h1, m1, s1, ms1, "-->", h2, m2, s2, ms2)
        h1, m1, s1, ms1, h2, m2, s2, ms2 = str(h1), str(m1), str(s1), str(ms1), str(h2), str(m2), str(s2), str(ms2)
        if len(h1) < 2:
            h1 = '0' + h1
        if len(m1) < 2:
            m1 = '0' + m1
        if len(s1) < 2:
            s1 = '0' + s1
        if len(ms1) == 1:
            ms1 = '00' + ms1
        if len(ms1) == 2:
            ms1 = '0' + ms1
        if len(h2) < 2:
            h2 = '0' + h2
        if len(m2) < 2:
            m2 = '0' + m2
        if len(s2) < 2:
            s2 = '0' + s2
        if len(ms2) == 1:
            ms2 = '00' + ms2
        if len(ms2) == 2:
            ms2 = '0' + ms2
        #print(h1, m1, s1, ms1, "-->", h2, m2, s2, ms2)
        #print()

        titlovi[i] = h1 + ':' + m1 + ':' + s1 + ',' + ms1 + ' --> ' + h2 + ':' + m2 + ':' + s2 + ',' + ms2

for i in range(len(titlovi)):
    if i == len(whatis) - 1:
        print(titlovi[i])
        print('#')
    elif whatis[i] == 3 and whatis[i + 1] == 1:
        print(titlovi[i])
        print()
    else:
        print(titlovi[i])
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3556 KB Output is correct
2 Correct 22 ms 3556 KB Output is correct
3 Incorrect 22 ms 3556 KB Output isn't correct
4 Incorrect 22 ms 3556 KB Output isn't correct
5 Incorrect 27 ms 3560 KB Output isn't correct