結果

問題 No.26 シャッフルゲーム
ユーザー GoryudyumaGoryudyuma
提出日時 2017-02-11 22:04:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 163 ms / 5,000 ms
コード長 661 bytes
コンパイル時間 3,156 ms
コンパイル使用メモリ 70,784 KB
実行使用メモリ 55,732 KB
最終ジャッジ日時 2023-08-28 14:47:02
合計ジャッジ時間 5,667 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,632 KB
testcase_01 AC 124 ms
55,676 KB
testcase_02 AC 163 ms
55,612 KB
testcase_03 AC 135 ms
55,220 KB
testcase_04 AC 142 ms
55,456 KB
testcase_05 AC 148 ms
55,272 KB
testcase_06 AC 154 ms
55,676 KB
testcase_07 AC 145 ms
55,508 KB
testcase_08 AC 163 ms
55,548 KB
testcase_09 AC 153 ms
55,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int p = sc.nextInt(), n = sc.nextInt();
                        for (int i = 0; i < n; i++) {
                                int a = sc.nextInt(), b = sc.nextInt();
                                if (a == p) {
                                        p = b;
                                } else if(b == p) {
                                        p = a;
                                }
                        }
                        System.out.println(p);
                }
        }
}
0