結果

問題 No.26 シャッフルゲーム
ユーザー SuunnSuunn
提出日時 2018-11-20 05:10:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 168 ms / 5,000 ms
コード長 364 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 71,688 KB
実行使用メモリ 56,404 KB
最終ジャッジ日時 2023-08-26 02:09:53
合計ジャッジ時間 4,814 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,000 KB
testcase_01 AC 123 ms
56,116 KB
testcase_02 AC 148 ms
56,020 KB
testcase_03 AC 134 ms
56,136 KB
testcase_04 AC 138 ms
55,900 KB
testcase_05 AC 153 ms
56,172 KB
testcase_06 AC 147 ms
56,404 KB
testcase_07 AC 137 ms
56,236 KB
testcase_08 AC 145 ms
56,208 KB
testcase_09 AC 168 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
	

public class Main{
	
	
	public static void main(String args[])throws Exception{
		
		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(N==p){
				N=q;
			}else if(N==q){
				N=p;
			}
		}
		System.out.println(N);
	}
	
}
0