結果
問題 | No.13 囲みたい! |
ユーザー | roiti46 |
提出日時 | 2015-02-23 16:25:48 |
言語 | Python2 (2.7.18) |
結果 |
RE
|
実行時間 | - |
コード長 | 634 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 7,188 KB |
実行使用メモリ | 14,244 KB |
最終ジャッジ日時 | 2023-09-06 03:07:16 |
合計ジャッジ時間 | 1,825 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
5,884 KB |
testcase_01 | AC | 11 ms
5,972 KB |
testcase_02 | AC | 11 ms
5,932 KB |
testcase_03 | AC | 33 ms
10,128 KB |
testcase_04 | RE | - |
testcase_05 | AC | 34 ms
9,356 KB |
testcase_06 | AC | 30 ms
6,368 KB |
testcase_07 | AC | 29 ms
6,380 KB |
testcase_08 | AC | 30 ms
6,336 KB |
testcase_09 | AC | 31 ms
6,336 KB |
testcase_10 | AC | 14 ms
6,040 KB |
testcase_11 | AC | 26 ms
6,112 KB |
testcase_12 | AC | 13 ms
6,004 KB |
testcase_13 | AC | 17 ms
5,940 KB |
testcase_14 | AC | 17 ms
6,144 KB |
testcase_15 | AC | 11 ms
5,964 KB |
ソースコード
import sys sys.setrecursionlimit(10000) dxy = zip([1,0,-1,0],[0,1,0,-1]) def dfs(x,y,c): A[y][x] = -c res = False cnt = 0 for dx,dy in dxy: nx,ny = x+dx,y+dy if 0 <= nx < W and 0 <= ny < H: if A[ny][nx] == c: res |= dfs(nx,ny,c) elif A[ny][nx] == -c: cnt += 1 return res or cnt > 1 W,H = map(int,raw_input().split()) A = [map(int,raw_input().split()) for i in xrange(H)] ans = False for y in xrange(H): for x in xrange(W): if A[y][x] > 0: ans |= dfs(x,y,A[y][x]) print "possible" if ans else "impossible"