結果

問題 No.26 シャッフルゲーム
ユーザー papipenpapipen
提出日時 2017-04-06 19:16:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 170 ms / 5,000 ms
コード長 337 bytes
コンパイル時間 3,419 ms
コンパイル使用メモリ 71,704 KB
実行使用メモリ 56,288 KB
最終ジャッジ日時 2023-09-24 21:02:14
合計ジャッジ時間 4,964 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,036 KB
testcase_01 AC 123 ms
55,700 KB
testcase_02 AC 159 ms
56,280 KB
testcase_03 AC 135 ms
55,648 KB
testcase_04 AC 141 ms
55,748 KB
testcase_05 AC 147 ms
56,028 KB
testcase_06 AC 147 ms
56,288 KB
testcase_07 AC 138 ms
56,080 KB
testcase_08 AC 149 ms
55,732 KB
testcase_09 AC 170 ms
56,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
class N026{
	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int m = s.nextInt();
		for(int i = 0; i < m; i++){
			int p = s.nextInt();
			int q = s.nextInt();
			if(p == n){
				n = q;
			}else if(q == n){
				n = p;
			}
		}
		System.out.println(n);
	}
}
0