結果
| 問題 |
No.5022 XOR Printer
|
| コンテスト | |
| ユーザー |
prussian_coder
|
| 提出日時 | 2025-07-25 20:59:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,000 ms |
| コード長 | 1,305 bytes |
| コンパイル時間 | 631 ms |
| コンパイル使用メモリ | 82,448 KB |
| 実行使用メモリ | 66,568 KB |
| スコア | 2,662,680,966 |
| 最終ジャッジ日時 | 2025-07-26 12:46:16 |
| 合計ジャッジ時間 | 5,854 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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(T):
print(ans[i])
prussian_coder