結果
| 問題 |
No.429 CupShuffle
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:19:19 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 164 ms / 2,000 ms |
| コード長 | 779 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 82,456 KB |
| 実行使用メモリ | 110,036 KB |
| 最終ジャッジ日時 | 2025-03-20 21:20:27 |
| 合計ジャッジ時間 | 2,380 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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])
lam6er