結果

問題 No.26 シャッフルゲーム
ユーザー パイソン勉強中パイソン勉強中
提出日時 2018-12-06 00:52:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 438 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 7,892 KB
最終ジャッジ日時 2023-10-11 04:43:11
合計ジャッジ時間 1,160 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,860 KB
testcase_01 AC 18 ms
7,812 KB
testcase_02 AC 18 ms
7,704 KB
testcase_03 AC 16 ms
7,816 KB
testcase_04 AC 16 ms
7,776 KB
testcase_05 AC 16 ms
7,892 KB
testcase_06 AC 17 ms
7,752 KB
testcase_07 AC 17 ms
7,780 KB
testcase_08 AC 17 ms
7,892 KB
testcase_09 AC 17 ms
7,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mainProc(n, ptns):
    lst = [0,0,0]
    lst[n-1] = 1

    for ptn in ptns:
        lst[ptn[0]-1], lst[ptn[1]-1] = lst[ptn[1]-1], lst[ptn[0]-1]
    
    for i in range(len(lst)):
        if lst[i] == 1 :
            print(str(i+1))

if __name__ == '__main__':
    
    n = int(input())
    m = int(input())
    ptns = []
    for i in range(m) :
        x, y = map(int,input().split())
        ptns.append((x, y))
    mainProc(n, ptns)
0