Submission #69486488


Source Code Expand

def f(X, t):
  global ans
  if X==h*w:
    ans = min(ans, t)
    return
  x, y = divmod(X, w)
  if x and y and all(A[i][j]=='#' for i, j in [(x, y), (x-1, y), (x, y-1), (x-1, y-1)]):
    A[x][y] = '.'
    f(X+1, t+1)
    A[x][y] = '#'
    A[x][y-1] = '.'
    f(X+1, t+1)
    A[x][y-1] = '#'
  else:
    f(X+1, t)



for _ in range(int(input())):
  h, w = map(int, input().split())
  A = [list(input()) for _ in range(h)]
  ans = 1<<60
  f(0, 0)
  print(ans)

  

Submission Info

Submission Time
Task D - 2x2 Erasing 2
User uparupaaa
Language Python (PyPy 3.10-v7.3.12)
Score 425
Code Size 486 Byte
Status AC
Exec Time 1192 ms
Memory 94376 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 1
AC × 27
Set Name Test Cases
Sample example_00.txt
All example_00.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
Case Name Status Exec Time Memory
example_00.txt AC 56 ms 76524 KiB
hand_00.txt AC 1192 ms 94376 KiB
hand_01.txt AC 72 ms 81656 KiB
hand_02.txt AC 96 ms 83464 KiB
hand_03.txt AC 57 ms 76480 KiB
hand_04.txt AC 755 ms 91844 KiB
hand_05.txt AC 56 ms 76364 KiB
random_00.txt AC 79 ms 81888 KiB
random_01.txt AC 83 ms 83000 KiB
random_02.txt AC 82 ms 82932 KiB
random_03.txt AC 82 ms 83116 KiB
random_04.txt AC 84 ms 83556 KiB
random_05.txt AC 107 ms 84580 KiB
random_06.txt AC 104 ms 83420 KiB
random_07.txt AC 134 ms 85556 KiB
random_08.txt AC 104 ms 83744 KiB
random_09.txt AC 191 ms 86096 KiB
random_10.txt AC 147 ms 84284 KiB
random_11.txt AC 286 ms 85528 KiB
random_12.txt AC 305 ms 85884 KiB
random_13.txt AC 334 ms 86856 KiB
random_14.txt AC 338 ms 87108 KiB
random_15.txt AC 142 ms 85160 KiB
random_16.txt AC 360 ms 88572 KiB
random_17.txt AC 365 ms 88040 KiB
random_18.txt AC 385 ms 88556 KiB
random_19.txt AC 369 ms 87332 KiB