結果
問題 |
No.5002 stick xor
|
ユーザー |
|
提出日時 | 2018-05-31 07:00:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 803 ms / 1,000 ms |
コード長 | 1,526 bytes |
コンパイル時間 | 26,900 ms |
実行使用メモリ | 6,008 KB |
スコア | 39,787 |
最終ジャッジ日時 | 2018-05-31 07:01:27 |
ジャッジサーバーID (参考情報) |
judge6 / |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
def main(): grid = [[0] * (N + 2)] apnd = grid.append for n in A: apnd([0] + n + [0]) apnd([0] * (N + 2)) for l in L: case1 = search1(l, grid) grid = list(map(list, zip(*grid))) case2 = search1(l, grid) if case1[0] > case2[0]: grid = list(map(list, zip(*grid))) _, row1, col1, row2, col2 = case1 line = grid[row1][col1:col2] grid[row1][col1:col2] = list(map(lambda x: int(not x), line)) print(row1, col1, row2, col2 - 1) else: _, row1, col1, row2, col2 = case2 line = grid[row1][col1:col2] grid[row1][col1:col2] = list(map(lambda x: int(not x), line)) row1, col1 = col1, row1 row2, col2 = col2, row2 grid = list(map(list, zip(*grid))) print(row1, col1, row2 - 1, col2) def search1(l, grid): max1 = 0 for i in range(1, N + 1): cnt = 0 for j in range(1, N + 1): if grid[i][j]: cnt += 1 if j >= l: col1 = (j - l) + 1 cnt -= grid[i][j-l] if max1 <= cnt: range_ = (max1, i, col1, i, col1 + l) max1 = cnt if cnt == l and not grid[i][col1-1] and not grid[i][col1+l]: return range_ return range_ N, K = map(int, input().split()) L = tuple(map(int, input().split())) A = [list(map(int, list(input()))) for _ in [0] * N] main()