結果
問題 |
No.5022 XOR Printer
|
ユーザー |
![]() |
提出日時 | 2025-07-10 12:40:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 1,628 bytes |
コンパイル時間 | 408 ms |
コンパイル使用メモリ | 82,656 KB |
実行使用メモリ | 57,008 KB |
スコア | 4,268,045,351 |
最終ジャッジ日時 | 2025-07-26 12:34:26 |
合計ジャッジ時間 | 4,604 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
ソースコード
# 乱択解法 # ターン数上限に至るまで以下を繰り返す # 現在位置からランダムにLRUDを選び、移動できる(盤面から出ない)ならば1手移動する # 20%の確率で操作Cする # 操作Wをすることで盤面が大きくなるのであれば操作Wをする 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] = [] 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 if random.random() < 0.2: ops.append("C") s_val ^= board[x][y] 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()