結果
問題 | No.5002 stick xor |
ユーザー |
![]() |
提出日時 | 2018-05-27 14:15:01 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,409 bytes |
コンパイル時間 | 30,118 ms |
実行使用メモリ | 5,732 KB |
スコア | 0 |
最終ジャッジ日時 | 2018-05-27 14:15:35 |
ジャッジサーバーID (参考情報) |
judge9 / |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 32 |
ソースコード
#!python# -*- coding: utf-8 -*-PRINT_STR = ""def output(y1, x1, y2, x2):global PRINT_STRPRINT_STR += "{} {} {} {}\n".format(y1, x1, y2, x2)def updete(grid, y1, x1, y2, x2):if y1 == y2:y = y1for x in range(x1, x2 + 1):grid[y][x] *= -1elif x1 == x2:x = x1for y in range(y1, y2 + 1):grid[y][x] *= -1def get_region(N, grid):max_score = 0max_score_length = 0max_score_region = (0, 0, 0, 0)for y in range(N):s = 0length = 0min_ = 0max_ = 0for x in range(N):s += grid[y][x]length += 1if max_ < s:max_ = sif s < min_:min_ = smax_ = min_length = 0score = max_ - min_if max_score < score:max_score = scoremax_score_length = lengthmax_score_region = (y, x - length + 1, y, x)elif max_score == score and max_score_length > length:max_score = scoremax_score_length = lengthmax_score_region = (y, x - length + 1, y, x)for x in range(N):s = 0length = 0min_ = 0max_ = 0for y in range(N):s += grid[y][x]length += 1if max_ < s:max_ = sif s < min_:min_ = smax_ = min_length = 0score = max_ - min_if max_score < score:max_score = scoremax_score_length = lengthmax_score_region = (y - length + 1, x, y, x)elif max_score == score and max_score_length > length:max_score = scoremax_score_length = lengthmax_score_region = (y - length + 1, x, y, x)return max_score_regiondef main():N, K = map(int, input().split())L = list(map(int, input().split()))grid = []for i in range(N):grid.append([])for c in input():grid[-1].append((c == '1') * 2 - 1)for k in range(K):region = get_region(N, grid)updete(grid, *region)output(*[i + 1 for i in region])if __name__ == '__main__':main()print(PRINT_STR)