提出 #69100916


ソースコード 拡げる

def solve():
    h, w = map(lambda s_: int(s_), input().split())
    s = [input() for _ in range(h)]

    def is_inside(x: int, y: int):
        return (0 <= x < h) and (0 <= y < w)
    dxyl = [(0, -1), (0, 1), (-1, 0), (1, 0)]
    # dxyl += [(1, 1), (1, -1), (-1, 1), (-1, -1)]
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                continue
            c = 0
            for di, dj in dxyl:
                ni, nj = i + di, j + dj
                if is_inside(ni, nj):
                    c += s[ni][nj] == "#"
            if c != 2 and c != 4:
                return False
    return True

case_t = 1
# case_t = int(input())
for _ in [None] * case_t:
    cond = solve()
    print("Yes" if cond else "No")



提出情報

提出日時
問題 B - Looped Rope
ユーザ wasd314
言語 Python (CPython 3.11.4)
得点 200
コード長 784 Byte
結果 AC
実行時間 10 ms
メモリ 8744 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 4
AC × 25
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 02_handmade_14.txt, 02_handmade_15.txt, 02_handmade_16.txt, 02_handmade_17.txt, 02_handmade_18.txt, 02_handmade_19.txt, 02_handmade_20.txt, 02_handmade_21.txt, 02_handmade_22.txt, 02_handmade_23.txt, 02_handmade_24.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 9 ms 8528 KiB
00_sample_01.txt AC 9 ms 8464 KiB
00_sample_02.txt AC 9 ms 8592 KiB
00_sample_03.txt AC 10 ms 8480 KiB
01_random_04.txt AC 9 ms 8512 KiB
01_random_05.txt AC 9 ms 8516 KiB
01_random_06.txt AC 9 ms 8536 KiB
01_random_07.txt AC 9 ms 8500 KiB
01_random_08.txt AC 9 ms 8472 KiB
01_random_09.txt AC 9 ms 8432 KiB
01_random_10.txt AC 9 ms 8412 KiB
01_random_11.txt AC 9 ms 8456 KiB
01_random_12.txt AC 9 ms 8488 KiB
01_random_13.txt AC 10 ms 8416 KiB
02_handmade_14.txt AC 9 ms 8416 KiB
02_handmade_15.txt AC 9 ms 8420 KiB
02_handmade_16.txt AC 9 ms 8552 KiB
02_handmade_17.txt AC 9 ms 8536 KiB
02_handmade_18.txt AC 9 ms 8584 KiB
02_handmade_19.txt AC 9 ms 8440 KiB
02_handmade_20.txt AC 10 ms 8744 KiB
02_handmade_21.txt AC 9 ms 8592 KiB
02_handmade_22.txt AC 9 ms 8556 KiB
02_handmade_23.txt AC 9 ms 8456 KiB
02_handmade_24.txt AC 9 ms 8480 KiB