結果
| 問題 |
No.5022 XOR Printer
|
| コンテスト | |
| ユーザー |
prussian_coder
|
| 提出日時 | 2025-07-25 15:34:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 1,186 bytes |
| コンパイル時間 | 403 ms |
| コンパイル使用メモリ | 82,292 KB |
| 実行使用メモリ | 64,512 KB |
| スコア | 2,650,873,290 |
| 最終ジャッジ日時 | 2025-07-26 12:45:16 |
| 合計ジャッジ時間 | 4,791 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
import random
# 入力
N, T = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
x, y = 0, 0 # 初期位置
s = 0
command_list = ["U", "D", "L", "R", "W", "C"]
def can_move(x: int, y: int, command: str) -> bool:
if command == "U":
return x > 0
elif command == "D":
return x < N - 1
elif command == "L":
return y > 0
elif command == "R":
return y < N - 1
return True
def process_command(board: list[list[int]], x: int, y: int, s: int, command: str):
if command == "U":
x, y = x - 1, y
elif command == "D":
x, y = x + 1, y
elif command == "L":
x, y = x, y - 1
elif command == "R":
x, y = x, y + 1
elif command == "W":
board[x][y] ^= s
elif command == "C":
s ^= board[x][y]
return board, x, y, s
def calc_score(board: list[list[int]]) -> int:
return sum(sum(board[i]) for i in range(N))
ans = []
while len(ans) < T:
command = random.choice(command_list)
if can_move(x, y, command):
A, x, y, s = process_command(A, x, y, s, command)
ans.append(command)
for i in range(N):
print(ans[i])
prussian_coder