結果

問題 No.26 シャッフルゲーム
ユーザー tentententen
提出日時 2020-11-10 10:04:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 163 ms / 5,000 ms
コード長 647 bytes
コンパイル時間 2,057 ms
コンパイル使用メモリ 71,020 KB
実行使用メモリ 56,556 KB
最終ジャッジ日時 2023-09-29 23:18:55
合計ジャッジ時間 4,171 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,728 KB
testcase_01 AC 116 ms
55,696 KB
testcase_02 AC 155 ms
56,080 KB
testcase_03 AC 125 ms
56,556 KB
testcase_04 AC 128 ms
55,412 KB
testcase_05 AC 134 ms
56,212 KB
testcase_06 AC 133 ms
56,032 KB
testcase_07 AC 132 ms
55,912 KB
testcase_08 AC 148 ms
55,840 KB
testcase_09 AC 163 ms
55,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean[] hasBall = new boolean[4];
        hasBall[sc.nextInt()] = true;
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int left = sc.nextInt();
            int right = sc.nextInt();
            boolean tmp = hasBall[left];
            hasBall[left] = hasBall[right];
            hasBall[right] = tmp;
        }
        for (int i = 1; i < 4; i++) {
            if (hasBall[i]) {
                System.out.println(i);
                return;
            }
        }
    }
}
0