結果
| 問題 | No.13 囲みたい! | 
| コンテスト | |
| ユーザー |  yaoshimax | 
| 提出日時 | 2015-02-10 12:55:31 | 
| 言語 | Python2 (2.7.18) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 792 bytes | 
| コンパイル時間 | 622 ms | 
| コンパイル使用メモリ | 7,040 KB | 
| 実行使用メモリ | 14,008 KB | 
| 最終ジャッジ日時 | 2024-06-23 18:06:03 | 
| 合計ジャッジ時間 | 7,350 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 5 TLE * 1 -- * 10 | 
ソースコード
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'
            
            
            
        