ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2023. Donald is a postman

Python-runtime_error
Posted by Klim Shramko 14 Mar 2023 04:27
Why does this code throw a runtime error?
Everything is right!!

from sys import stdin
pocht_1 = ["A", "P", "O", "R"]
pocht_2 = ["B", "M", "S"]
pocht_3 = ["D", "G", "J", "K", "T", "W"]
count = 0
mesto = 1
for i in sys.stdin.split("\n")[1:]:
    if i[0] in pocht_1:
        if mesto == 3:
            count += 2
        elif mesto == 2:
            count += 1
        mesto = 1
    elif i[0] in pocht_2:
        if mesto == 1:
            count += 1
        elif mesto == 3:
            count += 1
        mesto = 2
    else:
        if mesto == 1:
            count += 2
        elif mesto == 2:
            count += 1
        mesto = 3
print(count)