Submission #74274327


Source Code Expand

h,w=map(int,input().split())
g=[input().strip()for _ in range(h)]
v=[[0]*w for _ in range(h)]
ans=0

for i in range(h):
  for j in range(w):
    if g[i][j]=='.'and not v[i][j]:
      q=[(i,j)]
      v[i][j]=1
      ok=1
      for r,c in q:
        if r==0 or r==h-1 or c==0 or c==w-1:
          ok=0
        for dr,dc in[(0,1),(1,0),(0,-1),(-1,0)]:
          nr,nc=r+dr,c+dc
          if 0<=nr<h and 0<=nc<w and g[nr][nc]=='.'and not v[nr][nc]:
            v[nr][nc]=1
            q.append((nr,nc))
      if ok:ans+=1

print(ans)

Submission Info

Submission Time
Task C - Puddles
User ffrazi
Language Python (CPython 3.13.7)
Score 300
Code Size 550 Byte
Status AC
Exec Time 1282 ms
Memory 135456 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All min.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, random_20.txt, random_21.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
min.txt AC 10 ms 9320 KiB
random_01.txt AC 303 ms 18244 KiB
random_02.txt AC 95 ms 11780 KiB
random_03.txt AC 309 ms 18312 KiB
random_04.txt AC 159 ms 13636 KiB
random_05.txt AC 538 ms 18280 KiB
random_06.txt AC 24 ms 9408 KiB
random_07.txt AC 540 ms 18080 KiB
random_08.txt AC 30 ms 9504 KiB
random_09.txt AC 820 ms 69364 KiB
random_10.txt AC 591 ms 52028 KiB
random_11.txt AC 844 ms 69180 KiB
random_12.txt AC 15 ms 9448 KiB
random_13.txt AC 1054 ms 111848 KiB
random_14.txt AC 82 ms 14696 KiB
random_15.txt AC 1051 ms 111848 KiB
random_16.txt AC 325 ms 38076 KiB
random_17.txt AC 66 ms 18124 KiB
random_18.txt AC 1282 ms 135456 KiB
random_19.txt AC 656 ms 18112 KiB
random_20.txt AC 687 ms 76740 KiB
random_21.txt AC 670 ms 76776 KiB
sample_01.txt AC 11 ms 9352 KiB
sample_02.txt AC 11 ms 9284 KiB