Submission #24515584


Source Code Expand

II=lambda:int(input())


N=II()
K=II()
F=[[+(c=='.')for c in input()]+[0]for i in range(N)]+[[0]*(N+1)]

dh=[-1,0,1,0]
dw=[0,-1,0,1]
def dfs(h,w,i,l):
  if F[h][w]==0:
    return 0
  myl=l+[h*N+w]
  i+=1
  if i==K:
    c=str(sorted(myl))
    if c in s:
      return 0
    s.add(c)
    return 1
  myans=0
  for d,e in zip(dh,dw):
    nh=h+d
    nw=w+e
    myans+=dfs(nh,nw,i,myl)
  return myans
    

ans=0
for i in range(N*N):
  h,w=i//N,i%N
  s=set()
  ans+=dfs(h,w,0,[-1])
  F[h][w]=0
print(ans)

Submission Info

Submission Time
Task E - Red Polyomino
User Pandruant
Language PyPy3 (7.3.0)
Score 0
Code Size 498 Byte
Status WA
Exec Time 330 ms
Memory 82044 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 1
WA × 2
AC × 12
WA × 20
Set Name Test Cases
Sample example0.txt, example1.txt, example2.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, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt AC 72 ms 62200 KiB
001.txt AC 52 ms 62156 KiB
002.txt AC 47 ms 62044 KiB
003.txt AC 50 ms 61976 KiB
004.txt AC 49 ms 61960 KiB
005.txt AC 50 ms 62084 KiB
006.txt WA 53 ms 63708 KiB
007.txt WA 57 ms 64160 KiB
008.txt WA 52 ms 62328 KiB
009.txt WA 49 ms 62556 KiB
010.txt WA 50 ms 62104 KiB
011.txt WA 50 ms 62052 KiB
012.txt WA 264 ms 78212 KiB
013.txt WA 243 ms 77000 KiB
014.txt WA 102 ms 70024 KiB
015.txt WA 129 ms 71060 KiB
016.txt WA 104 ms 70720 KiB
017.txt WA 70 ms 68348 KiB
018.txt WA 277 ms 81176 KiB
019.txt WA 330 ms 82028 KiB
020.txt WA 273 ms 78548 KiB
021.txt WA 263 ms 78104 KiB
022.txt AC 52 ms 62080 KiB
023.txt AC 51 ms 61844 KiB
024.txt AC 44 ms 62004 KiB
025.txt AC 54 ms 62064 KiB
026.txt WA 154 ms 70176 KiB
027.txt AC 52 ms 62160 KiB
028.txt WA 244 ms 75304 KiB
example0.txt WA 51 ms 62020 KiB
example1.txt AC 56 ms 61748 KiB
example2.txt WA 330 ms 82044 KiB