結果

問題 No.26 シャッフルゲーム
ユーザー Mcpu3Mcpu3
提出日時 2018-06-22 01:53:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 331 bytes
コンパイル時間 1,852 ms
コンパイル使用メモリ 71,464 KB
実行使用メモリ 56,420 KB
最終ジャッジ日時 2023-09-13 07:48:49
合計ジャッジ時間 4,052 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,784 KB
testcase_01 AC 119 ms
55,872 KB
testcase_02 AC 154 ms
56,324 KB
testcase_03 AC 130 ms
56,132 KB
testcase_04 AC 135 ms
56,132 KB
testcase_05 AC 151 ms
55,936 KB
testcase_06 AC 152 ms
55,492 KB
testcase_07 AC 136 ms
56,032 KB
testcase_08 AC 144 ms
56,128 KB
testcase_09 AC 156 ms
56,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class no26{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n,m,p,q,i;
		n=stdIn.nextInt();
		m=stdIn.nextInt();
		for(i=0;i<m;i++) {
			p=stdIn.nextInt();
			q=stdIn.nextInt();
			if(p==n) n=q;
			else if(q==n) n=p;
		}
		System.out.print(n);
	}
}
0