結果
| 問題 |
No.5022 XOR Printer
|
| コンテスト | |
| ユーザー |
prussian_coder
|
| 提出日時 | 2025-07-23 13:36:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 1,262 bytes |
| コンパイル時間 | 868 ms |
| コンパイル使用メモリ | 82,104 KB |
| 実行使用メモリ | 56,836 KB |
| スコア | 3,533,036,613 |
| 最終ジャッジ日時 | 2025-07-26 12:41:37 |
| 合計ジャッジ時間 | 4,105 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
# 乱択解法(最初のコピーのみ)
import random
import sys
def main() -> None:
n, t = map(int, sys.stdin.readline().split())
board = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
x, y = 0, 0
s_val = 0
ops: list[str] = []
ops.append("C")
s_val = board[x][y]
while len(ops) < t:
directions = []
if x > 0:
directions.append("U")
if x + 1 < n:
directions.append("D")
if y > 0:
directions.append("L")
if y + 1 < n:
directions.append("R")
if directions:
move = random.choice(directions)
ops.append(move)
if move == "U":
x -= 1
elif move == "D":
x += 1
elif move == "L":
y -= 1
elif move == "R":
y += 1
else:
# No available moves; should not happen on a valid board
break
if len(ops) >= t:
break
new_val = board[x][y] ^ s_val
if new_val > board[x][y]:
ops.append("W")
board[x][y] = new_val
sys.stdout.write("\n".join(ops) + "\n")
if __name__ == "__main__":
main()
prussian_coder