結果
| 問題 |
No.123 カードシャッフル
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-07 23:59:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 927 ms / 5,000 ms |
| コード長 | 741 bytes |
| コンパイル時間 | 280 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 16,624 KB |
| 最終ジャッジ日時 | 2025-11-07 23:59:39 |
| 合計ジャッジ時間 | 3,809 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
ソースコード
class Node:
def __init__(self, x):
self.x = x
self.prev = None
self.next = None
n, m = map(int, input().split())
a = list(map(int, input().split()))
root = Node(1)
current = root
for i in range(2, n + 1):
node = Node(i)
current.next = node
node.prev = current
current = node
for x in a:
current = root
cnt = 1
while cnt < x:
current = current.next
cnt += 1
if current.prev:
if current.next:
current.prev.next = current.next
current.next.prev = current.prev
else:
current.prev.next = None
current.prev = None
current.next = root
root.prev = current
root = current
print(root.x)