結果

問題 No.26 シャッフルゲーム
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-23 18:14:51
言語 Java19
(openjdk 21)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 744 bytes
コンパイル時間 2,797 ms
コンパイル使用メモリ 71,744 KB
実行使用メモリ 49,760 KB
最終ジャッジ日時 2023-09-29 15:57:18
合計ジャッジ時間 4,369 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
49,228 KB
testcase_01 AC 36 ms
49,120 KB
testcase_02 AC 39 ms
49,168 KB
testcase_03 AC 37 ms
49,352 KB
testcase_04 AC 38 ms
49,500 KB
testcase_05 AC 39 ms
49,676 KB
testcase_06 AC 38 ms
49,512 KB
testcase_07 AC 37 ms
49,416 KB
testcase_08 AC 37 ms
49,204 KB
testcase_09 AC 38 ms
49,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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



public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        int M = Integer.parseInt(reader.readLine());

        String[] line;
        for (int i = 0; i < M; i++) {
            line = reader.readLine().split(" ");
            int p = Integer.parseInt(line[0]);
            int q = Integer.parseInt(line[1]);
            if (p == N) {
                N = q;
            } else if (q == N) {
                N = p;
            }
        }
        System.out.println(N);
    }
}
0