結果

問題 No.26 シャッフルゲーム
ユーザー matsuyoshi30
提出日時 2016-03-27 15:12:41
言語 Java
(openjdk 23)
結果
AC  
実行時間 177 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 74,204 KB
実行使用メモリ 42,112 KB
最終ジャッジ日時 2024-10-02 04:35:50
合計ジャッジ時間 4,266 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        for(int i=0; i<m; i++) {
            int p = in.nextInt();
            int q = in.nextInt();
            if(p == n) {
                n = q;
            } else if(q == n) {
                n = p;
            }
        }

        System.out.println(n);
    }
}
0