結果
問題 | No.460 裏表ちわーわ |
ユーザー | h_noson |
提出日時 | 2017-01-26 23:29:11 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,069 bytes |
コンパイル時間 | 232 ms |
コンパイル使用メモリ | 10,904 KB |
実行使用メモリ | 8,368 KB |
最終ジャッジ日時 | 2023-08-25 01:41:46 |
合計ジャッジ時間 | 16,124 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
8,212 KB |
testcase_01 | AC | 16 ms
8,168 KB |
testcase_02 | AC | 105 ms
8,244 KB |
testcase_03 | AC | 16 ms
8,240 KB |
testcase_04 | AC | 15 ms
8,148 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 1,062 ms
8,176 KB |
testcase_09 | AC | 25 ms
8,304 KB |
testcase_10 | AC | 1,068 ms
8,164 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 1,118 ms
8,080 KB |
testcase_14 | AC | 1,098 ms
8,240 KB |
testcase_15 | AC | 1,114 ms
8,340 KB |
testcase_16 | WA | - |
testcase_17 | AC | 1,076 ms
8,112 KB |
testcase_18 | AC | 1,092 ms
8,188 KB |
testcase_19 | AC | 1,113 ms
8,188 KB |
testcase_20 | WA | - |
testcase_21 | AC | 1,093 ms
8,276 KB |
testcase_22 | AC | 1,073 ms
8,192 KB |
testcase_23 | AC | 1,092 ms
8,168 KB |
testcase_24 | AC | 1,117 ms
8,368 KB |
testcase_25 | AC | 16 ms
8,120 KB |
testcase_26 | AC | 17 ms
8,108 KB |
testcase_27 | AC | 18 ms
8,176 KB |
ソースコード
INF = 10**9 dx = [-1,-1,-1, 0, 1, 1, 1, 0] dy = [-1, 0, 1, 1, 1, 0,-1,-1] def dfs(y,x): if x == n: if y > 0: for j in range(n): if a[y-1][j]: return INF return dfs(y+1,0) elif y == m: for i in range(m): for j in range(n): if a[i][j]: return INF return 0 ret = INF if x == 0 or y == 0 or a[y-1][x-1]: a[y][x] ^= 1 for i in range(8): ny = y + dy[i] nx = x + dx[i] if ny < 0 or ny >= m or nx < 0 or nx >= n: continue a[ny][nx] ^= 1 ret = min(ret,dfs(y,x+1)+1) a[y][x] ^= 1 for i in range(8): ny = y + dy[i] nx = x + dx[i] if ny < 0 or ny >= m or nx < 0 or nx >= n: continue a[ny][nx] ^= 1 if x == 0 or y == 0 or not a[y-1][x-1]: ret = min(ret,dfs(y,x+1)) return ret m,n = map(int,input().split(' ')) a = [list(map(int,input().split(' '))) for i in range(m)] print(dfs(0,0))