結果

問題 No.26 シャッフルゲーム
ユーザー koukonkokoukonko
提出日時 2015-12-07 13:39:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 800 bytes
コンパイル時間 3,627 ms
コンパイル使用メモリ 71,684 KB
実行使用メモリ 49,708 KB
最終ジャッジ日時 2023-10-12 19:56:39
合計ジャッジ時間 3,267 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,304 KB
testcase_01 AC 43 ms
49,708 KB
testcase_02 AC 46 ms
49,420 KB
testcase_03 AC 44 ms
49,160 KB
testcase_04 AC 45 ms
49,328 KB
testcase_05 AC 45 ms
49,220 KB
testcase_06 AC 46 ms
49,248 KB
testcase_07 AC 45 ms
49,196 KB
testcase_08 AC 46 ms
49,348 KB
testcase_09 AC 47 ms
49,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

		try {
			int N = Integer.parseInt(buff.readLine());
			int M = Integer.parseInt(buff.readLine());

			for(int i = 0; i < M; ++i){
				String[] str = buff.readLine().split(" ");
				int[] box = new int[2];
				boolean flag = false;
				for(int j = 0; j < 2; ++j){
					box[j] = Integer.parseInt(str[j]);
					if(N == box[j]){
						flag = true;
					}
				}
				if(flag){
					if(N == box[0]){
						N = box[1];
					}else{
						N = box[0];
					}
				}
			}

			System.out.println(N);
		} catch (NumberFormatException e) {

		} catch (IOException e) {

		}
	}
}
0