結果

問題 No.5002 stick xor
ユーザー GrayCoder
提出日時 2018-05-27 22:16:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 991 bytes
コンパイル時間 26,660 ms
実行使用メモリ 5,956 KB
スコア 34,558
最終ジャッジ日時 2018-05-27 22:16:38
ジャッジサーバーID
(参考情報)
judge8 /
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30 TLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    grid = [[0] * (N + 2)]
    for n in A:
        grid.append([0] + n + [0])
    grid.append([0] * (N + 2))

    for l in L:
        case1 = search(l, grid)
        _, row1, col1, row2, col2 = case1
        hline = grid[row1][col1:col2]
        grid[row1][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
                    ret = [maxb, i, j, i, j + l]
                    return ret
            if maxb < black:
                maxb = black
                ret = [maxb, i, j, i, 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