結果

問題 No.862 XORでX
ユーザー risujirohrisujiroh
提出日時 2019-08-09 23:12:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,806 bytes
コンパイル時間 1,767 ms
コンパイル使用メモリ 172,936 KB
実行使用メモリ 8,228 KB
最終ジャッジ日時 2023-09-26 21:52:45
合計ジャッジ時間 5,188 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 4 ms
4,384 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 28 ms
6,856 KB
testcase_20 AC 37 ms
8,116 KB
testcase_21 AC 36 ms
8,228 KB
testcase_22 AC 37 ms
8,068 KB
testcase_23 AC 37 ms
8,176 KB
testcase_24 AC 37 ms
8,116 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 37 ms
8,004 KB
testcase_28 AC 37 ms
8,060 KB
testcase_29 AC 37 ms
8,112 KB
testcase_30 AC 37 ms
8,060 KB
testcase_31 AC 37 ms
8,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, x; cin >> n >> x;
  if (n == 2) {
    if (x == 1) {
      cout << 2 << '\n';
      cout << 3 << '\n';
    } else {
      cout << 1 << '\n';
      cout << (x ^ 1) << '\n';
    }
    return 0;
  }

  set<int> res;
  auto add = [&](int l, int r) -> void {
    for (int i = l; i < r; ++i) {
      res.insert(i);
    }
  };

  if (n % 4 == 0) {
    if (x < 4) {
      if (n == 4) {
        res.insert(16 | x);
        res.insert(20);
        res.insert(24);
        res.insert(28);
      } else {
        add(1, n + 4);
        res.erase(4 | x);
        int y = x < 3 ? x + 1 : 1;
        res.erase(y);
        res.erase(4 | y);
      }
    } else {
      add(1, 4);
      int m = n / 4 - 1;
      for (int i = 4; m; i += 4) {
        if (i <= x and x < i + 4) continue;
        add(i, i + 4);
        --m;
      }
      res.insert(x);
    }
  } else if (n % 4 == 1) {
    int m = n / 4;
    for (int i = 4; m; i += 4) {
      if (i <= x and x < i + 4) continue;
      add(i, i + 4);
      --m;
    }
    res.insert(x);
  } else if (n % 4 == 2) {
    for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) {
      res.insert(i);
    }
    add(1, 4);
    int m = n / 4;
    for (int i = 4; m; i += 4) {
      if (i <= x and x < i + 4) continue;
      add(i, i + 4);
      --m;
    }
  } else {
    for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) {
      res.insert(i);
    }
    int m = n / 4;
    for (int i = 4; m; i += 4) {
      if (i <= x and x < i + 4) continue;
      add(i, i + 4);
      --m;
    }
  }

  for (int e : res) {
    cout << e << '\n';
  }
}
0