結果

問題 No.26 シャッフルゲーム
ユーザー abcabc
提出日時 2016-10-20 13:24:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 628 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 71,968 KB
実行使用メモリ 56,460 KB
最終ジャッジ日時 2023-08-15 08:48:07
合計ジャッジ時間 3,960 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,788 KB
testcase_01 AC 117 ms
56,048 KB
testcase_02 AC 149 ms
55,888 KB
testcase_03 AC 123 ms
55,672 KB
testcase_04 AC 128 ms
55,856 KB
testcase_05 AC 143 ms
55,760 KB
testcase_06 AC 141 ms
55,764 KB
testcase_07 AC 129 ms
55,772 KB
testcase_08 AC 131 ms
56,460 KB
testcase_09 AC 144 ms
56,232 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