結果

問題 No.429 CupShuffle
コンテスト
ユーザー 👑 yumechi
提出日時 2016-10-02 23:31:02
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 100 ms / 2,000 ms
+ 670µs
コード長 778 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 64 ms
コンパイル使用メモリ 82,088 KB
実行使用メモリ 102,868 KB
最終ジャッジ日時 2026-09-27 14:09:50
合計ジャッジ時間 2,249 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def solve():
    n, k, x = map(int, input().split())
    start = [i for i in range(n)]
    executelist = []
    for i in range(k):
        li = input().split()
        a, b = 0, 0
        if(i != x-1):
            a, b = map(lambda inp: int(inp)-1, li)
        else:
            a, b = "?", "?"
        executelist.append([a, b])
    end = [int(i) - 1 for i in input().split()]

    for i in range(x-1):
        f, s = executelist[i][0], executelist[i][1]
        start[f], start[s] = start[s], start[f]
    for i in range(k-1, x-1, -1):
        f, s = executelist[i][0], executelist[i][1]
        end[f], end[s] = end[s], end[f]
    ans = []
    for i in range(n):
        if start[i] != end[i]:
            ans.append(i+1)
    print(*ans)

if __name__=="__main__":
    solve()
0