結果
| 問題 | No.5002 stick xor | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-05-29 22:47:42 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 722 ms / 1,000 ms | 
| コード長 | 1,496 bytes | 
| コンパイル時間 | 23,337 ms | 
| 実行使用メモリ | 6,020 KB | 
| スコア | 38,713 | 
| 最終ジャッジ日時 | 2018-05-29 22:48:07 | 
| ジャッジサーバーID (参考情報) | judge7 / | 
| 純コード判定しない問題か言語 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 32 | 
ソースコード
def main():
    grid = [[2] * (N + 2)]
    apnd = grid.append
    for n in A:
        apnd([2] + n + [2])
    apnd([2] * (N + 2))
    for i, l in enumerate(L):
        if i < 250:
            case1 = search(l, 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:
            if i == 250:
                grid = list(map(list, zip(*grid)))
            case2 = search(l, grid)
            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
            print(row1, col1, row2 - 1, col2)
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 == 1 and grid[i][j] == 1:
                if grid[i][j-1] == grid[i][j+1] == grid[i-1][j] == grid[i+1][j] == 0:
                    return (i, j, i, j + 1)
            elif black == l and grid[i][j-1] == grid[i][j+l] == 0:
                return (i, j, i, j + l)
            elif maxb < black:
                maxb = black
                ret = (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()
            
            
            
        