結果
問題 | No.5002 stick xor |
ユーザー | GrayCoder |
提出日時 | 2018-05-27 23:39:28 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 767 ms / 1,000 ms |
コード長 | 1,554 bytes |
コンパイル時間 | 24,927 ms |
実行使用メモリ | 6,020 KB |
スコア | 37,289 |
最終ジャッジ日時 | 2018-05-27 23:39:54 |
ジャッジサーバーID (参考情報) |
judge9 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 712 ms
6,020 KB |
testcase_01 | AC | 685 ms
6,016 KB |
testcase_02 | AC | 742 ms
6,016 KB |
testcase_03 | AC | 767 ms
6,020 KB |
testcase_04 | AC | 702 ms
6,020 KB |
testcase_05 | AC | 727 ms
6,020 KB |
testcase_06 | AC | 689 ms
6,016 KB |
testcase_07 | AC | 753 ms
6,016 KB |
testcase_08 | AC | 716 ms
6,016 KB |
testcase_09 | AC | 755 ms
6,020 KB |
testcase_10 | AC | 710 ms
6,016 KB |
testcase_11 | AC | 753 ms
6,020 KB |
testcase_12 | AC | 705 ms
6,020 KB |
testcase_13 | AC | 740 ms
6,020 KB |
testcase_14 | AC | 707 ms
6,012 KB |
testcase_15 | AC | 734 ms
6,016 KB |
testcase_16 | AC | 692 ms
6,020 KB |
testcase_17 | AC | 754 ms
6,012 KB |
testcase_18 | AC | 709 ms
6,016 KB |
testcase_19 | AC | 753 ms
6,020 KB |
testcase_20 | AC | 686 ms
6,020 KB |
testcase_21 | AC | 750 ms
6,020 KB |
testcase_22 | AC | 704 ms
6,020 KB |
testcase_23 | AC | 760 ms
6,016 KB |
testcase_24 | AC | 693 ms
6,020 KB |
testcase_25 | AC | 735 ms
6,016 KB |
testcase_26 | AC | 732 ms
6,020 KB |
testcase_27 | AC | 739 ms
6,016 KB |
testcase_28 | AC | 731 ms
6,016 KB |
testcase_29 | AC | 729 ms
6,020 KB |
testcase_30 | AC | 721 ms
6,020 KB |
testcase_31 | AC | 722 ms
6,020 KB |
ソースコード
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 = search(l, grid) _, row1, col1, row2, col2 = case1 for i in range(row1, row2 + 1): hline = grid[i][col1:col2] grid[i][col1:col2] = list(map(lambda x: int(not x), hline)) print(row1, col1, row2, col2 - 1) def search(l, grid): maxb = -1 for i in range(1, N + 1): for j in range(1, N + 2 - l): black = grid[i][j:j+l].count(1) if l == black == 1: if grid[i][j-1] == grid[i][j+1] == grid[i-1][j] == grid[i+1][j] == 0: maxb = black return (maxb, i, j, i, j + l) elif l == 2 and grid[i][j] and not grid[i][j-1] and not grid[i][j+1]: if grid[i+1][j] == 1: maxb = black return (maxb, i, j, i + 1, j + 1) elif l == 3 and grid[i][j] and not grid[i][j-1] and not grid[i][j+1]: if grid[i-1][j] == 1 and grid[i+1][j] == 1: maxb = black return (maxb, i - 1, j, i + 1, j + 1) elif maxb < black: maxb = black ret = (maxb, i, j, i, j + l) if black == l and grid[i][j-1] == grid[i][j+l] == 0: return ret return ret N, K = map(int, input().split()) L = tuple(map(int, input().split())) A = [list(map(int, list(input()))) for _ in [0] * N] main()