提出 #50300193


ソースコード 拡げる

#ABC293 C - Make Takahashi Happy
from collections import deque
H, W = map(int, input().split())
A = []
for x in range(H):
    a = list(map(int, input().split()))
    A.append(a)
#print(A)

q = deque([[0, 0]])
pre = [-1]*(H+W-1)
count = 0

while q:
    cnt = q.popleft()
    x, y = cnt
    pre[x+y] = A[x][y]
    if x == H-1 and y == W-1:
        if len(pre) == len(set(pre)):
            count += 1
#            print(pre)
    else:
        nx = [x+1, y]
        ny = [x, y+1]
        if x+1 < H:
            q.appendleft(nx)
        if y+1 < W:
            q.appendleft(ny)

#    print(q)
#    print(pre)
print(count)

提出情報

提出日時
問題 C - Make Takahashi Happy
ユーザ pakaaaaaaaaaa
言語 Python (CPython 3.11.4)
得点 300
コード長 649 Byte
結果 AC
実行時間 117 ms
メモリ 9352 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 25
セット名 テストケース
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, example0.txt, example1.txt
ケース名 結果 実行時間 メモリ
000.txt AC 12 ms 9200 KiB
001.txt AC 103 ms 9212 KiB
002.txt AC 103 ms 9260 KiB
003.txt AC 105 ms 9272 KiB
004.txt AC 102 ms 9248 KiB
005.txt AC 103 ms 9108 KiB
006.txt AC 117 ms 9280 KiB
007.txt AC 14 ms 9352 KiB
008.txt AC 12 ms 9160 KiB
009.txt AC 12 ms 9192 KiB
010.txt AC 114 ms 9188 KiB
011.txt AC 113 ms 9164 KiB
012.txt AC 115 ms 9264 KiB
013.txt AC 113 ms 9184 KiB
014.txt AC 117 ms 9224 KiB
015.txt AC 111 ms 9180 KiB
016.txt AC 107 ms 9220 KiB
017.txt AC 105 ms 9096 KiB
018.txt AC 110 ms 9280 KiB
019.txt AC 111 ms 9288 KiB
020.txt AC 107 ms 9120 KiB
021.txt AC 106 ms 9252 KiB
022.txt AC 105 ms 9256 KiB
example0.txt AC 12 ms 9100 KiB
example1.txt AC 112 ms 9348 KiB