結果

問題 No.26 シャッフルゲーム
ユーザー Grenache
提出日時 2015-09-22 23:15:37
言語 Java
(openjdk 23)
結果
AC  
実行時間 164 ms / 5,000 ms
コード長 479 bytes
コンパイル時間 3,265 ms
コンパイル使用メモリ 74,208 KB
実行使用メモリ 42,056 KB
最終ジャッジ日時 2024-07-19 08:42:30
合計ジャッジ時間 5,085 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder26 {

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
        	int p = sc.nextInt();
        	int q = sc.nextInt();
        	
        	if (p == n) {
        		n = q;
        	} else if (q == n) {
        		n = p;
        	}
        }

		System.out.println(n);

		sc.close();
    }
}
0