結果

問題 No.26 シャッフルゲーム
ユーザー yagi2
提出日時 2017-04-26 11:49:16
言語 Java
(openjdk 23)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 589 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 74,632 KB
実行使用メモリ 54,196 KB
最終ジャッジ日時 2024-09-13 14:01:19
合計ジャッジ時間 4,280 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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