Skip to content
On this page

2565_1_Quiz_3_1.py

TIP

อยากลอกก็ย้อนเวลาไปลอกสิครับ

py
n = int(input())

team_to_country = {}

for i in range(n):
    team, country = input().split(" ")
    team_to_country[team] = country

def validate(teams):
    seen = set()
    for team in teams:
        if team not in team_to_country.keys():
            return False

        country = team_to_country[team]
        if country in seen:
            return False
        seen.add(country)

    return True

while True:
    token = input()

    if token == "q":
        break

    teams = token.split(" ")

    if validate(teams):
        print("OK")
    else:
        print("Not OK")

People who plagiarize Com Prog HW and cannot do exam:

People who do Com Prog HW by themself and can do exam easily:

Released under the MIT License