結果
| 問題 | No.13 囲みたい! |
| コンテスト | |
| ユーザー |
yaoshimax
|
| 提出日時 | 2015-02-10 12:55:31 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 4,841 ms / 5,000 ms |
| コード長 | 792 bytes |
| 記録 | |
| コンパイル時間 | 153 ms |
| コンパイル使用メモリ | 77,596 KB |
| 最終ジャッジ日時 | 2025-12-03 13:46:53 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
W,H=map(int,raw_input().split())
M=[]
for i in range(H):
Ms = map(int,raw_input().split())
M.append(Ms)
dx=[1,0,-1,0]
dy=[0,1,0,-1]
for a in range(H):
for b in range(W):
arrived=[[False for i in range(W)] for j in range(H)]
st = [(a,b,1)]
while len(st)!=0:
i,j,dist = st.pop()
if arrived[i][j]:
continue
arrived[i][j]=True
for x,y in zip(dx,dy):
ni = i+x
nj = j+y
if ni >= 0 and ni < H and nj >= 0 and nj <W:
if M[ni][nj]==M[i][j]:
if a== ni and b == nj and dist >= 3:
print 'possible'
exit()
elif not arrived[ni][nj]:
st.append((ni,nj,dist+1))
print 'impossible'
yaoshimax