結果

問題 No.26 シャッフルゲーム
ユーザー abcabc
提出日時 2016-10-20 13:24:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 628 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 73,680 KB
実行使用メモリ 41,632 KB
最終ジャッジ日時 2024-05-02 20:29:05
合計ジャッジ時間 3,687 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
41,168 KB
testcase_01 AC 110 ms
40,768 KB
testcase_02 AC 139 ms
41,372 KB
testcase_03 AC 122 ms
41,380 KB
testcase_04 AC 121 ms
41,356 KB
testcase_05 AC 126 ms
41,388 KB
testcase_06 AC 135 ms
41,164 KB
testcase_07 AC 126 ms
41,192 KB
testcase_08 AC 144 ms
41,376 KB
testcase_09 AC 148 ms
41,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int initialCircle =sc.nextInt();
        int numChange = sc.nextInt();

        int currentCircle = initialCircle;

        for (int i = 0; i < numChange; i++) {

            int from = sc.nextInt();
            int to = sc.nextInt();

            if (from == currentCircle) {

                currentCircle = to;

            } else if (to == currentCircle) {

                currentCircle = from;

            }

        }

        System.out.println(currentCircle);

    }

}
0