結果
| 問題 |
No.1379 Postponed
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 22:55:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,209 bytes |
| コンパイル時間 | 251 ms |
| コンパイル使用メモリ | 81,592 KB |
| 実行使用メモリ | 75,244 KB |
| 最終ジャッジ日時 | 2025-04-15 22:57:23 |
| 合計ジャッジ時間 | 6,689 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 40 TLE * 1 -- * 23 |
ソースコード
n, k = map(int, input().split())
original = list(map(int, input().split()))
current = original.copy()
steps = 0
found_cycle = False
cycle_length = 0
# First pass to detect cycle
while steps < k:
if current == original:
if steps != 0:
# Found a cycle
cycle_length = steps
remaining = k % cycle_length
k = remaining
found_cycle = True
break
a_prev = current[0]
m = a_prev + 1
if m > n:
m = n
rotated_part = current[1:m] + [current[0]]
new_current = rotated_part + current[m:]
current = new_current
steps += 1
# Check after incrementing steps
if current == original and steps != 0:
cycle_length = steps
remaining = k % cycle_length
k = remaining
found_cycle = True
break
# If cycle found, reset and simulate remaining steps
if found_cycle:
current = original.copy()
steps = 0
while steps < k:
a_prev = current[0]
m = a_prev + 1
if m > n:
m = n
rotated_part = current[1:m] + [current[0]]
current = rotated_part + current[m:]
steps += 1
print(' '.join(map(str, current)))
lam6er