結果

問題 No.26 シャッフルゲーム
コンテスト
ユーザー abc
提出日時 2016-10-20 13:24:04
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,256 ms
コンパイル使用メモリ 81,484 KB
実行使用メモリ 43,136 KB
最終ジャッジ日時 2026-05-17 07:46:11
合計ジャッジ時間 4,123 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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