結果

問題 No.862 XORでX
ユーザー htensai
提出日時 2019-12-25 11:37:50
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,359 bytes
コンパイル時間 1,916 ms
コンパイル使用メモリ 77,824 KB
実行使用メモリ 56,656 KB
最終ジャッジ日時 2024-09-24 17:59:41
合計ジャッジ時間 10,189 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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