#!/usr/bin/env python3 import sys def fail(msg): print(msg, file=sys.stderr) sys.exit(43) with open(sys.argv[1]) as infile, open(sys.argv[2]) as ansfile: team_output = sys.stdin.read() is_impossible = ansfile.read().strip() == 'impossible' if is_impossible: if team_output.strip().lower() != 'impossible': sane_team_output = team_output.rstrip().replace('\n', '\\n') if len(sane_team_output) > 80: sane_team_output = sane_team_output[:80] + '[...]' fail(f"Expected 'impossible', got '{sane_team_output}'") else: sys.exit(42) # Team correctly outputs 'impossible' # After this, the test case must be possible. if 'impossible' in team_output.lower(): # super-lenient about case and spam fail("Rejects yes-instance") n, m, k = map(int, map(int, infile.readline().split())) edges = [] for line in infile: edges.append(line.split()) team_tokens = team_output.split() if not team_tokens: fail("Team output is empty") try: r = int(team_tokens[0]) except ValueError: fail(f"Integer expected, got {team_tokens[0]}") if len(team_tokens[1:]) != r: fail(f"Team promised {r} vertices, but provided {len(team_tokens[1:])}") try: U = set(map(int, team_tokens[1:])) except ValueError: fail(f"Integers expected, got {team_tokens[1:]}") # TODO more checks covered = 0 for e in edges: u, v = map(int, e) if u in U or v in U: covered += 1 if covered != k: fail(f"Covered {covered} edges, expected {k}") sys.exit(42)