Submission #9110349


Source Code Expand

import heapq
que = []
N = 3
A = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
    for j in range(N):
        heapq.heappush(que, (-A[i][j], i, j))
dire = [(0, 1), (1, 0), (0, -1), (-1, 0)]
def search(a, x, y):
    if a == 0:
        return
    for dx, dy in dire:
        if 0<=x+dx<N and 0<=y+dy<N:
            if A[x+dx][y+dy] == a:
                A[x+dx][y+dy]-=1
                search(a-1, x+dx, y+dy)
                return
    return

while que:
    a, i, j = heapq.heappop(que)
    a = -a
    if A[i][j] != a and A[i][j]>0:
        heapq.heappush(que, (-A[i][j], i, j))
    print(i+1, j+1)
    a-=1
    A[i][j]-=1
    search(a, i, j)
    if a>0:
        heapq.heappush(que, (-a, i, j))


Submission Info

Submission Time
Task A - 高橋君の山崩しゲーム
User masayoshi64
Language PyPy3 (2.4.0)
Score 0
Code Size 754 Byte
Status WA
Exec Time 428 ms
Memory 62172 KB

Judge Result

Set Name test_01 test_02 test_03 test_04 test_05 test_06 test_07 test_08 test_09 test_10
Score / Max Score 0 / 100000 0 / 100000 0 / 100000 0 / 100000 0 / 100000 0 / 100000 0 / 100000 0 / 100000 0 / 100000 0 / 100000
Status
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
Set Name Test Cases
test_01 subtask_01_01.txt
test_02 subtask_01_02.txt
test_03 subtask_01_03.txt
test_04 subtask_01_04.txt
test_05 subtask_01_05.txt
test_06 subtask_01_06.txt
test_07 subtask_01_07.txt
test_08 subtask_01_08.txt
test_09 subtask_01_09.txt
test_10 subtask_01_10.txt
Case Name Status Exec Time Memory
subtask_01_01.txt WA 364 ms 54620 KB
subtask_01_02.txt WA 345 ms 53468 KB
subtask_01_03.txt WA 353 ms 55384 KB
subtask_01_04.txt WA 385 ms 56540 KB
subtask_01_05.txt WA 382 ms 56028 KB
subtask_01_06.txt WA 428 ms 62172 KB
subtask_01_07.txt WA 348 ms 54108 KB
subtask_01_08.txt WA 337 ms 53228 KB
subtask_01_09.txt WA 373 ms 55512 KB
subtask_01_10.txt WA 376 ms 57820 KB