結果

問題 No.26 シャッフルゲーム
ユーザー yagi2yagi2
提出日時 2017-04-26 11:49:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 71,876 KB
実行使用メモリ 56,200 KB
最終ジャッジ日時 2023-10-11 15:11:32
合計ジャッジ時間 3,974 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,864 KB
testcase_01 AC 117 ms
56,168 KB
testcase_02 AC 143 ms
55,868 KB
testcase_03 AC 125 ms
55,704 KB
testcase_04 AC 126 ms
55,788 KB
testcase_05 AC 133 ms
56,200 KB
testcase_06 AC 133 ms
55,884 KB
testcase_07 AC 123 ms
55,572 KB
testcase_08 AC 138 ms
56,020 KB
testcase_09 AC 140 ms
55,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder.No26;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int circle = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        for (int i = 0; i < M; i++) {
            int b = Integer.parseInt(sc.next());
            int a = Integer.parseInt(sc.next());

            if (b == circle) {
                circle = a;
            } else if (a == circle) {
                circle = b;
            }
        }
        System.out.println(circle);
    }
}
0