結果
問題 |
No.429 CupShuffle
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:59:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 779 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 82,296 KB |
実行使用メモリ | 109,648 KB |
最終ジャッジ日時 | 2025-03-20 19:00:22 |
合計ジャッジ時間 | 2,135 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
n, k_total, x = map(int, input().split()) operations = [] for _ in range(k_total): a, b = input().split() operations.append((a, b)) c = list(map(int, input().split())) # Reconstruct S1: initial state up to X-1 exchanges s1 = list(range(1, n + 1)) for k in range(1, x): a_str, b_str = operations[k - 1] a = int(a_str) b = int(b_str) s1[a-1], s1[b-1] = s1[b-1], s1[a-1] # Reconstruct S2: final state after undoing exchanges after X s2 = c.copy() for k in range(k_total, x, -1): a_str, b_str = operations[k - 1] a = int(a_str) b = int(b_str) s2[a-1], s2[b-1] = s2[b-1], s2[a-1] # Find differing positions diff = [] for i in range(n): if s1[i] != s2[i]: diff.append(i + 1) # 1-based index diff.sort() print(diff[0], diff[1])