結果

問題 No.26 シャッフルゲーム
ユーザー GrenacheGrenache
提出日時 2015-09-22 23:15:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 168 ms / 5,000 ms
コード長 479 bytes
コンパイル時間 3,103 ms
コンパイル使用メモリ 72,008 KB
実行使用メモリ 58,392 KB
最終ジャッジ日時 2023-09-26 14:30:08
合計ジャッジ時間 5,343 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,900 KB
testcase_01 AC 122 ms
58,392 KB
testcase_02 AC 168 ms
58,048 KB
testcase_03 AC 133 ms
55,960 KB
testcase_04 AC 137 ms
55,480 KB
testcase_05 AC 144 ms
55,680 KB
testcase_06 AC 145 ms
56,196 KB
testcase_07 AC 136 ms
55,920 KB
testcase_08 AC 148 ms
56,444 KB
testcase_09 AC 157 ms
56,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder26 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
        	int p = sc.nextInt();
        	int q = sc.nextInt();
        	
        	if (p == n) {
        		n = q;
        	} else if (q == n) {
        		n = p;
        	}
        }

		System.out.println(n);

		sc.close();
    }
}
0