broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    out=[]
    for draws in commands:
        occluded=set()
        visible=[]
        for key,coverage,opaque,clip,writes in reversed(draws):
            effective=set(coverage)&set(clip)&set(writes)&full
            remaining=effective-occluded
            visible.append([key,sorted(remaining)])
            if opaque: occluded |= set(coverage)
        out.append(list(reversed(visible)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 4), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 4), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 4), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 4), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 4), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 4), [[['a', [0, 1, 2, 3]]]])
if N == 2:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 5), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 5), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 5), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 5), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 5), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 5), [[['a', [0, 1, 2, 3, 4]]]])
if N == 3:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 6), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 6), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 6), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 6), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 6), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 6), [[['a', [0, 1, 2, 3, 4, 5]]]])
if N == 4:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 7), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 7), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 7), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 7), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 7), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 7), [[['a', [0, 1, 2, 3, 4, 5, 6]]]])
if N == 5:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 8), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 8), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 8), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 8), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 8), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 8), [[['a', [0, 1, 2, 3, 4, 5, 6, 7]]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    out=[]
    for draws in commands:
        occluded=set()
        visible=[]
        for key,coverage,opaque,clip,writes in reversed(draws):
            effective=set(coverage)&set(clip)&set(writes)&full
            remaining=effective-occluded
            visible.append([key,sorted(remaining)])
            if opaque: occluded |= set(coverage)&full
        out.append(list(reversed(visible)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 4), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 4), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 4), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 4), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 4), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 4), [[['a', [0, 1, 2, 3]]]])
if N == 2:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 5), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 5), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 5), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 5), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 5), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 5), [[['a', [0, 1, 2, 3, 4]]]])
if N == 3:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 6), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 6), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 6), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 6), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 6), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 6), [[['a', [0, 1, 2, 3, 4, 5]]]])
if N == 4:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 7), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 7), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 7), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 7), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 7), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 7), [[['a', [0, 1, 2, 3, 4, 5, 6]]]])
if N == 5:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 8), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 8), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 8), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 8), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 8), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 8), [[['a', [0, 1, 2, 3, 4, 5, 6, 7]]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Occlusion history stores primitive coverage before clip and write masking.

Draws are supplied back to front as ID, coverage set, opaque flag, clip set and sample-write-enable set. Visibility traverses front to back, subtracting only front opaque written samples. Transparent draws remain visible but do not occlude. Return every draw in original order, including empty visibility, labeled by ID. Repeated IDs are distinct draws. All coverage is finite-target bounded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    out=[]
    for draws in commands:
        occluded=set()
        visible=[]
        for key,coverage,opaque,clip,writes in reversed(draws):
            effective=set(coverage)&set(clip)&set(writes)&full
            remaining=effective-occluded
            visible.append([key,sorted(remaining)])
            if opaque: occluded |= effective
        out.append(visible)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 4), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 4), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 4), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 4), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 4), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 4), [[['a', [0, 1, 2, 3]]]])
if N == 2:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 5), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 5), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 5), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 5), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 5), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 5), [[['a', [0, 1, 2, 3, 4]]]])
if N == 3:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 6), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 6), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 6), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 6), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 6), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 6), [[['a', [0, 1, 2, 3, 4, 5]]]])
if N == 4:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 7), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 7), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 7), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 7), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 7), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 7), [[['a', [0, 1, 2, 3, 4, 5, 6]]]])
if N == 5:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 8), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 8), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 8), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 8), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 8), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 8), [[['a', [0, 1, 2, 3, 4, 5, 6, 7]]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    out=[]
    for draws in commands:
        occluded=set()
        visible=[]
        for key,coverage,opaque,clip,writes in reversed(draws):
            effective=set(coverage)&set(clip)&set(writes)&full
            remaining=effective-occluded
            visible.append([key,sorted(remaining)])
            if opaque: occluded |= effective
        out.append(sorted(visible,key=lambda row:row[0]))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 4), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 4), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 4), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 4), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 4), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 4), [[['a', [0, 1, 2, 3]]]])
if N == 2:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 5), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 5), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 5), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 5), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 5), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 5), [[['a', [0, 1, 2, 3, 4]]]])
if N == 3:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 6), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 6), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 6), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 6), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 6), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 6), [[['a', [0, 1, 2, 3, 4, 5]]]])
if N == 4:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 7), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 7), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 7), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 7), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 7), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 7), [[['a', [0, 1, 2, 3, 4, 5, 6]]]])
if N == 5:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 8), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 8), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 8), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 8), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 8), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 8), [[['a', [0, 1, 2, 3, 4, 5, 6, 7]]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Visibility records are returned in front-to-back traversal order rather than original submission order.

Draws are supplied back to front as ID, coverage set, opaque flag, clip set and sample-write-enable set. Visibility traverses front to back, subtracting only front opaque written samples. Transparent draws remain visible but do not occlude. Return every draw in original order, including empty visibility, labeled by ID. Repeated IDs are distinct draws. All coverage is finite-target bounded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    out=[]
    for draws in commands:
        occluded=set()
        visible=[]
        for key,coverage,opaque,clip,writes in reversed(draws):
            effective=set(coverage)&set(clip)&set(writes)&full
            remaining=effective-occluded
            if remaining: visible.append([key,sorted(remaining)])
            if opaque: occluded |= effective
        out.append(list(reversed(visible)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 4), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 4), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 4), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 4), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 4), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 4), [[['a', [0, 1, 2, 3]]]])
if N == 2:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 5), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 5), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 5), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 5), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 5), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 5), [[['a', [0, 1, 2, 3, 4]]]])
if N == 3:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 6), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 6), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 6), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 6), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 6), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 6), [[['a', [0, 1, 2, 3, 4, 5]]]])
if N == 4:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 7), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 7), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 7), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 7), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 7), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 7), [[['a', [0, 1, 2, 3, 4, 5, 6]]]])
if N == 5:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 8), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 8), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 8), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 8), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 8), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 8), [[['a', [0, 1, 2, 3, 4, 5, 6, 7]]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    out=[]
    for draws in commands:
        occluded=set()
        visible=[]
        for key,coverage,opaque,clip,writes in reversed(draws):
            effective=set(coverage)&set(clip)&set(writes)&full
            remaining=effective-occluded
            if remaining or opaque: visible.append([key,sorted(remaining)])
            if opaque: occluded |= effective
        out.append(list(reversed(visible)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 4), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 4), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 4), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 4), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 4), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 4), [[['a', [0, 1, 2, 3]]]])
if N == 2:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 5), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 5), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 5), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 5), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 5), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 5), [[['a', [0, 1, 2, 3, 4]]]])
if N == 3:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 6), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 6), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 6), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 6), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 6), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 6), [[['a', [0, 1, 2, 3, 4, 5]]]])
if N == 4:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 7), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 7), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 7), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 7), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 7), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 7), [[['a', [0, 1, 2, 3, 4, 5, 6]]]])
if N == 5:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 8), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 8), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 8), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 8), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 8), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 8), [[['a', [0, 1, 2, 3, 4, 5, 6, 7]]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Fully clipped or occluded draws lose their explicit empty visibility records.

Draws are supplied back to front as ID, coverage set, opaque flag, clip set and sample-write-enable set. Visibility traverses front to back, subtracting only front opaque written samples. Transparent draws remain visible but do not occlude. Return every draw in original order, including empty visibility, labeled by ID. Repeated IDs are distinct draws. All coverage is finite-target bounded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    out=[]
    for draws in commands:
        occluded=set()
        visible=[]
        for key,coverage,opaque,clip,writes in reversed(draws):
            effective=set(coverage)&set(clip)&set(writes)&full
            remaining=effective-occluded
            visible=[v for v in visible if v[0]!=key]+[[key,sorted(remaining)]]
            if opaque: occluded |= effective
        out.append(list(reversed(visible)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 4), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 4), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 4), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 4), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 4), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 4), [[['a', [0, 1, 2, 3]]]])
if N == 2:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 5), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 5), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 5), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 5), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 5), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 5), [[['a', [0, 1, 2, 3, 4]]]])
if N == 3:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 6), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 6), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 6), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 6), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 6), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 6), [[['a', [0, 1, 2, 3, 4, 5]]]])
if N == 4:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 7), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 7), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 7), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 7), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 7), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 7), [[['a', [0, 1, 2, 3, 4, 5, 6]]]])
if N == 5:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 8), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 8), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 8), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 8), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 8), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 8), [[['a', [0, 1, 2, 3, 4, 5, 6, 7]]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    out=[]
    for draws in commands:
        occluded=set()
        visible=[]
        for key,coverage,opaque,clip,writes in reversed(draws):
            effective=set(coverage)&set(clip)&set(writes)&full
            remaining=effective-occluded
            if not any(v[0]==key for v in visible): visible.append([key,sorted(remaining)])
            if opaque: occluded |= effective
        out.append(list(reversed(visible)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 4), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 4), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 4), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 4), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 4), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 4), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 4), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 4), [[['a', [0, 1, 2, 3]]]])
if N == 2:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 5), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 5), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 5), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 5), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 5), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 5), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 5), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 5), [[['a', [0, 1, 2, 3, 4]]]])
if N == 3:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 6), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 6), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 6), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 6), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 6), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 6), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 6), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 6), [[['a', [0, 1, 2, 3, 4, 5]]]])
if N == 4:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 7), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 7), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 7), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 7), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 7), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 7), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 7), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 7), [[['a', [0, 1, 2, 3, 4, 5, 6]]]])
if N == 5:
    check('explicit sequence 0', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 1', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], False, [0, 1], [0, 1]]]], 8), [[['back', [0, 1]], ['front', [0, 1]]]])
    check('explicit sequence 2', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0], [0, 1]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 3', solve([[['back', [0, 1], True, [0, 1], [0, 1]], ['front', [0, 1], True, [0, 1], [0]]]], 8), [[['back', [1]], ['front', [0]]]])
    check('explicit sequence 4', solve([[['back', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [0]], ['front', [1]]]])
    check('explicit sequence 5', solve([[['back', [0, 1, 2], True, [0, 1, 2], [0, 1, 2]], ['middle', [0], True, [0], [0]], ['front', [1], True, [1], [1]]]], 8), [[['back', [2]], ['middle', [0]], ['front', [1]]]])
    check('explicit sequence 6', solve([[['z', [0], False, [0], [0]], ['a', [1], False, [1], [1]]]], 8), [[['z', [0]], ['a', [1]]]])
    check('explicit sequence 7', solve([[['a', [0], False, [], [0]], ['b', [1], True, [1], [1]]]], 8), [[['a', []], ['b', [1]]]])
    check('explicit sequence 8', solve([[['same', [0], False, [0], [0]], ['same', [1], False, [1], [1]]]], 8), [[['same', [0]], ['same', [1]]]])
    check('explicit sequence 9', solve([[['a', [0], True, [0], []]]], 8), [[['a', []]]])
    check('explicit sequence 10', solve([[['a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]]], 8), [[['a', [0, 1, 2, 3, 4, 5, 6, 7]]]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Visibility output deduplicates draw IDs and loses separate submissions.

Draws are supplied back to front as ID, coverage set, opaque flag, clip set and sample-write-enable set. Visibility traverses front to back, subtracting only front opaque written samples. Transparent draws remain visible but do not occlude. Return every draw in original order, including empty visibility, labeled by ID. Repeated IDs are distinct draws. All coverage is finite-target bounded.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full: ids[x]=None; depths[x]=float('inf')
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if x in full else None for x in cmd[1]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(commands, size):
    full=set(range(size))
    ids=[None]*size
    depths=[float('inf')]*size
    out=[]
    for cmd in commands:
        if cmd[0]=='clear':
            for x in set(cmd[1])&full: ids[x]=None; depths[x]=float('inf')
        elif cmd[0]=='draw':
            _,key,coverage,clip,depth,test,write=cmd
            for x in set(coverage)&(set(clip) or full)&full:
                if test and depth>=depths[x]: continue
                if test: depths[x]=depth
                if write: ids[x]=key
        else:
            out.append([ids[x] if x in full else None for x in cmd[1]])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 4), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 4), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 4), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 4), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 4), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 4), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 4), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 4), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 4), [[None]])
if N == 2:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 5), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 5), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 5), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 5), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 5), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 5), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 5), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 5), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 5), [[None]])
if N == 3:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 6), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 6), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 6), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 6), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 6), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 6), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 6), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 6), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 6), [[None]])
if N == 4:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 7), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 7), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 7), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 7), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 7), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 7), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 7), [[None, 'a', None, None]])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 7), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 7), [[None]])
if N == 5:
    check('explicit sequence 0', solve([['draw', 'a', [0, 1], [0], 3, True, True], ['read', [0, 1]]], 8), [['a', None]])
    check('explicit sequence 1', solve([['draw', 'a', [0], [0], 3, True, True], ['draw', 'b', [0], [0], 3, True, True], ['read', [0]]], 8), [['a']])
    check('explicit sequence 2', solve([['draw', 'a', [0], [0], 1, False, True], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 3', solve([['draw', 'a', [0], [0], 1, True, False], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [[None]])
    check('explicit sequence 4', solve([['draw', 0, [0], [0], 1, True, True], ['read', [0]]], 8), [[0]])
    check('explicit sequence 5', solve([['draw', 'a', [0], [0], 1, False, False], ['read', [0]]], 8), [[None]])
    check('explicit sequence 6', solve([['draw', 'a', [0], [0], 1, True, True], ['clear', [0]], ['draw', 'b', [0], [0], 2, True, True], ['read', [0]]], 8), [['b']])
    check('explicit sequence 7', solve([['draw', 'a', [0, 1], [0, 1], 1, True, True], ['clear', [0]], ['read', [0, 1]], ['clear', []], ['read', [1]]], 8), [[None, 'a'], ['a']])
    check('explicit sequence 8', solve([['draw', 'a', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 1, True, True], ['read', [-1, 0, 99, 7]]], 8), [[None, 'a', None, 'a']])
    check('explicit sequence 9', solve([['draw', 'a', [0], [0], 1, True, True], ['draw', 'b', [1], [1], 1, True, True], ['read', [1, 0, 1]]], 8), [['b', 'a', 'b']])
    check('explicit sequence 10', solve([['draw', 'a', [0], [], 1, True, True], ['read', [0]]], 8), [[None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The picking attachment writes IDs outside the raster clip.

Each draw has an object ID, coverage samples, clip samples, integer depth, depth-test flag and ID-write flag. ID zero is a valid object. Pick samples start empty with infinite depth. With depth test enabled, strictly nearer fragments replace stored IDs and depth; equal depth keeps the earlier fragment. Disabled depth testing writes without changing depth. ID-write-disabled draws still update depth when tested. Queries return IDs or null for out-of-target samples.

split: open-access