提出 #69074088


ソースコード 拡げる

from sys import stdin
def input():
    return stdin.readline().rstrip("\n")

n, q = map(lambda s_: int(s_), input().split())
s = [input() for _ in range(n)]
ss = "".join(s)

acc = [[0] * (n) for _ in range(n)]
for i in range(1, n):
    for j in range(1, n):
        p = i * n + j
        if all(ss[x] == "." for x in (p - 1 - n, p - n, p - 1, p)):
            acc[i][j] = 1
for i in range(n - 1):
    for j in range(n):
        acc[i + 1][j] += acc[i][j]
for i in range(n):
    for j in range(n - 1):
        acc[i][j + 1] += acc[i][j]

def total(il, ir, jl, jr):
    return acc[ir][jr] - acc[il][jr] - acc[ir][jl] + acc[il][jl]

for _ in range(q):
    il, ir, jl, jr = map(lambda s_: int(s_), input().split())
    il -= 1
    jl -= 1
    ir -= 1
    jr -= 1
    print(total(il, ir, jl, jr))


提出情報

提出日時
問題 A - 2x2 Erasing
ユーザ wasd314
言語 Python (PyPy 3.10-v7.3.12)
得点 400
コード長 827 Byte
結果 AC
実行時間 205 ms
メモリ 87428 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 28
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 56 ms 76320 KiB
00_sample_01.txt AC 57 ms 76384 KiB
01_handmade_00.txt AC 113 ms 84128 KiB
01_handmade_01.txt AC 167 ms 86216 KiB
01_handmade_02.txt AC 58 ms 76336 KiB
01_handmade_03.txt AC 193 ms 87428 KiB
01_handmade_04.txt AC 174 ms 86568 KiB
02_random_00.txt AC 177 ms 85804 KiB
02_random_01.txt AC 146 ms 83944 KiB
02_random_02.txt AC 202 ms 86104 KiB
02_random_03.txt AC 134 ms 83688 KiB
02_random_04.txt AC 128 ms 83844 KiB
02_random_05.txt AC 189 ms 86680 KiB
02_random_06.txt AC 202 ms 86464 KiB
02_random_07.txt AC 205 ms 86664 KiB
02_random_08.txt AC 204 ms 86580 KiB
02_random_09.txt AC 205 ms 86828 KiB
02_random_10.txt AC 171 ms 86480 KiB
02_random_11.txt AC 166 ms 86668 KiB
02_random_12.txt AC 169 ms 86420 KiB
02_random_13.txt AC 171 ms 86440 KiB
02_random_14.txt AC 179 ms 87120 KiB
02_random_15.txt AC 178 ms 86648 KiB
02_random_16.txt AC 177 ms 86340 KiB
02_random_17.txt AC 176 ms 86788 KiB
02_random_18.txt AC 178 ms 86472 KiB
02_random_19.txt AC 173 ms 86712 KiB
02_random_20.txt AC 188 ms 87416 KiB