結果

問題 No.5002 stick xor
ユーザー GrayCoder
提出日時 2018-05-27 21:25:08
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 968 bytes
コンパイル時間 22,157 ms
実行使用メモリ 5,944 KB
スコア 31,972
最終ジャッジ日時 2018-05-27 21:25:58
ジャッジサーバーID
(参考情報)
judge7 /
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

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