結果
問題 | No.5002 stick xor |
ユーザー | kerotono |
提出日時 | 2018-05-27 22:10:11 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,994 bytes |
コンパイル時間 | 2,473 ms |
実行使用メモリ | 6,504 KB |
スコア | 0 |
最終ジャッジ日時 | 2018-05-27 22:10:15 |
ジャッジサーバーID (参考情報) |
judge7 / |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
ソースコード
#!python # -*- coding: utf-8 -*- from pprint import pprint import pyperclip PRINT_STR = "" def output(y1, x1, y2, x2): global PRINT_STR PRINT_STR += "{} {} {} {}\n".format(y1, x1, y2, x2) def updete(grid, y1, x1, y2, x2): if y1 == y2: y = y1 for x in range(x1, x2 + 1): grid[y][x] *= -1 elif x1 == x2: x = x1 for y in range(y1, y2 + 1): grid[y][x] *= -1 def get_region(N, grid, length): global TOTAL_SCORE max_score = float('-inf') max_score_region = (0, 0, 0, 0) for y in range(N): for x in range(N - length + 1): if x == 0: score = 0 for i in range(length): score += grid[y][i] else: score -= grid[y][x - 1] score += grid[y][x + length - 1] if max_score < score: max_score = score max_score_region = (y, x, y, x + length - 1) for x in range(N): for y in range(N - length + 1): if y == 0: score = 0 for i in range(length): score += grid[i][x] else: score -= grid[y - 1][x] score += grid[y + length - 1][x] if max_score < score: max_score = score max_score_region = (y, x, y + length - 1, x) return max_score_region def main(): N, K = map(int, input().split()) L = [[int(n), i] for i, n in enumerate(input().split())] L.sort(reverse=True, key=(lambda a: a[0])) grid = [] for i in range(N): grid.append([]) for c in input(): grid[-1].append((c == '1') * 2 - 1) for k in range(K): L[k].append(get_region(N, grid, L[k][0])) updete(grid, *L[k][2]) L.sort(key=(lambda a: a[1])) for a in L: output(*[i + 1 for i in a[2]]) if __name__ == '__main__': main() print(PRINT_STR)