結果

問題 No.5002 stick xor
ユーザー GrayCoderGrayCoder
提出日時 2018-05-26 12:27:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 862 ms / 1,000 ms
コード長 706 bytes
コンパイル時間 27,676 ms
実行使用メモリ 5,920 KB
スコア 36,841
最終ジャッジ日時 2018-05-26 12:27:49
ジャッジサーバーID
(参考情報)
judge9 /
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    a = A
    for l in L:
        case1 = challenge(l, a)
        _, row1, col1, row2, col2 = case1
        invert = a[row1-1][col1-1:col2]
        a[row1-1][col1-1:col2] = list(map(lambda x: int(not x), invert))
        print(row1, col1, row2, col2)

def challenge(l, grid):
    maxb = -1
    ret = []
    for i, r in enumerate(grid):
        for j in range(N + 1 - l):
            black = r[j:j+l].count(1)
            if maxb < black:
                maxb = black
                row = i + 1
                ret = [maxb, row, j + 1, row, j + l]
    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()
0