Олимпиада НТИ по ВР 2019, 2 этап / std.quiz

ru en cn

с начала прошло: 2194 д. 13:02
страница обновлена: 24.11.2024 04:02

std.quiz: check_quiz.py

import sys
import itertools

def PE(msg):
    print(msg)
    quit(2)
def WA(msg):
    print(msg)
    quit(1)

def check_one(o, a):
    o = o.lower()
    a = a.lower()
    return set(o.split()) == set(a.split())

try:
    fin, fout, fans = map(open, sys.argv[1:4])
    out = fout.readlines()
    ans = fans.readlines()
    #if len(out) < len(ans): PE(f"Too few lines: {len(out)} < {len(ans)}")
    if len(out) > len(ans): PE(f"Too many lines: {len(out)} > {len(ans)}")

    for i, (o, a) in enumerate(itertools.zip_longest(out, ans)):
        if o is None or not any(check_one(o, p) for p in a.split('|')):
            WA('' if len(ans) ==1 else f"line: {i + 1}")
    print("ok")
    quit(0)

except Exception as e:
    print(e)
    quit(2)
Дальневосточный федеральный университет