結果

問題 No.26 シャッフルゲーム
ユーザー kou6839
提出日時 2014-11-18 15:13:37
言語 Java
(openjdk 23)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 338 bytes
コンパイル時間 2,004 ms
コンパイル使用メモリ 75,988 KB
実行使用メモリ 55,432 KB
最終ジャッジ日時 2025-01-02 17:02:15
合計ジャッジ時間 4,247 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 

public class Main {
	
	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 a = sc.nextInt();
			int b = sc.nextInt();
			if(a==n) n=b;
			else if(b==n) n=a;
		}
		System.out.println(n);
	}
}			
0