結果

問題 No.26 シャッフルゲーム
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-03-27 15:12:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 170 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 74,080 KB
実行使用メモリ 54,472 KB
最終ジャッジ日時 2024-04-10 03:13:19
合計ジャッジ時間 4,211 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
54,164 KB
testcase_01 AC 129 ms
54,024 KB
testcase_02 AC 170 ms
54,252 KB
testcase_03 AC 145 ms
54,244 KB
testcase_04 AC 145 ms
54,388 KB
testcase_05 AC 162 ms
54,272 KB
testcase_06 AC 150 ms
54,376 KB
testcase_07 AC 142 ms
54,472 KB
testcase_08 AC 149 ms
54,184 KB
testcase_09 AC 154 ms
54,244 KB
権限があれば一括ダウンロードができます

ソースコード

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