結果

問題 No.862 XORでX
ユーザー htensaihtensai
提出日時 2019-12-25 11:37:50
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,359 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 77,412 KB
実行使用メモリ 60,380 KB
最終ジャッジ日時 2023-10-24 22:55:23
合計ジャッジ時間 12,277 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
57,228 KB
testcase_01 AC 131 ms
57,248 KB
testcase_02 AC 131 ms
57,504 KB
testcase_03 AC 136 ms
55,440 KB
testcase_04 AC 133 ms
57,504 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 167 ms
57,668 KB
testcase_09 AC 162 ms
57,468 KB
testcase_10 AC 169 ms
57,508 KB
testcase_11 AC 166 ms
57,536 KB
testcase_12 AC 136 ms
57,496 KB
testcase_13 AC 134 ms
57,636 KB
testcase_14 AC 134 ms
57,680 KB
testcase_15 AC 133 ms
57,504 KB
testcase_16 WA -
testcase_17 AC 197 ms
59,800 KB
testcase_18 AC 201 ms
60,160 KB
testcase_19 AC 196 ms
59,916 KB
testcase_20 AC 204 ms
59,868 KB
testcase_21 AC 207 ms
60,024 KB
testcase_22 AC 208 ms
60,128 KB
testcase_23 AC 213 ms
60,008 KB
testcase_24 AC 210 ms
59,672 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 208 ms
59,988 KB
testcase_29 AC 207 ms
60,272 KB
testcase_30 AC 210 ms
60,060 KB
testcase_31 AC 210 ms
60,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] result = new int[n];
        int mod = n % 4;
        if (mod == 0) {
            n--;
            result[n] = x;
            n--;
            result[n] = 1;
            n--;
            result[n] = 100005;
            n--;
            result[n] = 100004;
        } else if (mod == 1) {
            n--;
            result[n] = x;
        } else if (mod == 2) {
            n--;
            result[n] = x ^ 1;
            n--;
            result[n] = 1;
        } else {
            n--;
            result[n] = x ^ 1;
            n--;
            result[n] = 100005;
            n--;
            result[n] = 100004;
        }
        int idx = 2;
        while (n > 0) {
            if (idx == x || idx + 1 == x || idx == (x ^ 1) || idx + 1 == (x ^ 1)) {
                idx += 2;
                continue;
            }
            n--;
            result[n] = idx;
            idx++;
            n--;
            result[n] = idx;
            idx++;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < result.length; i++) {
            sb.append(result[i]).append("\n");
        }
        System.out.print(sb);
    }
}
0