File size: 2,059 Bytes
01a492e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

import subprocess
import sys
from pathlib import Path

cases = [{'input': '2\n3 2\n3 1 3 2\n1 2 2 2\n1 0 0 1\n', 'output': '1\n'}, {'input': '3\n10 10\n1 2 1 1\n5 5 6 5\n6 4 5 4\n2 1 2 0\n', 'output': '2\n'}, {'input': '2\n2 2\n2 1 1 1\n1 2 2 2\n1 0 0 0\n', 'output': '-1\n'}, {'input': '1\n1 2\n1 1 1 2\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n2 1\n2 1 1 1\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n1000 1000\n63 902 63 901\n0 0 0 0\n', 'output': '1\n'}, {'input': '6\n10 10\n3 6 3 7\n4 9 5 9\n5 4 5 3\n7 1 8 1\n9 10 8 10\n7 7 7 8\n0 5 2 3\n', 'output': '1\n'}, {'input': '2\n4 4\n3 1 3 2\n2 2 2 1\n0 0 0 0\n', 'output': '-1\n'}, {'input': '2\n2 2\n1 1 1 2\n2 1 2 2\n0 1 1 1\n', 'output': '1\n'}, {'input': '2\n2 2\n1 1 1 2\n2 1 2 2\n1 0 1 1\n', 'output': '2\n'}, {'input': '2\n2 2\n1 1 1 2\n2 1 2 2\n0 1 1 0\n', 'output': '-1\n'}, {'input': '1\n1 2\n1 2 1 1\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n1 3\n1 2 1 3\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n1 4\n1 2 1 1\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n1 5\n1 4 1 3\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n1 6\n1 6 1 5\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n1 7\n1 6 1 7\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n2 1\n2 1 1 1\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n2 2\n2 2 2 1\n0 0 0 0\n', 'output': '1\n'}, {'input': '1\n2 3\n1 2 1 1\n0 0 0 0\n', 'output': '1\n'}]
solution = Path(__file__).with_name("solution.py")
for index, case in enumerate(cases):
    proc = subprocess.run(
        [sys.executable, str(solution)],
        input=case["input"],
        text=True,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        timeout=10,
    )
    if proc.returncode != 0:
        raise AssertionError(f"case {index} exited {proc.returncode}: {proc.stderr}")
    got = proc.stdout.strip()
    expected = case["output"].strip()
    if got.split() != expected.split():
        raise AssertionError(
            f"case {index} output mismatch\nexpected={expected!r}\ngot={got!r}\nstderr={proc.stderr}"
        )
print('deepcoder_primeintellect_io')