結果

問題 No.26 シャッフルゲーム
ユーザー spaciaspacia
提出日時 2015-12-30 19:20:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 74,776 KB
実行使用メモリ 53,524 KB
最終ジャッジ日時 2023-10-19 12:42:01
合計ジャッジ時間 3,175 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
53,512 KB
testcase_01 AC 52 ms
53,512 KB
testcase_02 AC 56 ms
53,516 KB
testcase_03 AC 55 ms
52,480 KB
testcase_04 AC 53 ms
53,524 KB
testcase_05 AC 53 ms
53,516 KB
testcase_06 AC 53 ms
53,520 KB
testcase_07 AC 52 ms
53,516 KB
testcase_08 AC 54 ms
53,508 KB
testcase_09 AC 54 ms
52,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main26 {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		int ans = Integer.parseInt(br.readLine());
		int m = Integer.parseInt(br.readLine());
		
		for (int i = 0; i < m; i++) {
			String[] line = br.readLine().split(" ");
			int p = Integer.parseInt(line[0]);
			int q = Integer.parseInt(line[1]);
			ans = ans == p ? q : ans == q ? p : ans;
		}
		
		out(ans);
	}
}
0