結果

問題 No.26 シャッフルゲーム
ユーザー YOSHI
提出日時 2021-02-17 23:19:51
言語 Java
(openjdk 23)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 529 bytes
コンパイル時間 3,845 ms
コンパイル使用メモリ 80,108 KB
実行使用メモリ 41,788 KB
最終ジャッジ日時 2024-09-14 08:07:44
合計ジャッジ時間 6,190 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.stream.Stream;

public class No00000026_Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = Integer.parseInt(scan.nextLine());
		int m = Integer.parseInt(scan.nextLine());
		for(int i = 0; i < m; i++) {
			int[] arr = Stream.of(scan.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
			if(arr[0] == n) {
				n = arr[1];
			} else if(arr[1] == n) {
				n = arr[0];
			}
		}

		System.out.println(n);

		scan.close();

	}

}
0