結果

問題 No.862 XORでX
ユーザー risujirohrisujiroh
提出日時 2019-08-09 22:42:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,287 bytes
コンパイル時間 1,552 ms
コンパイル使用メモリ 167,020 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-26 20:57:21
合計ジャッジ時間 6,448 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
  V<> res;
  auto add = [&](int l, int r) -> void {
    for (int i = l; i < r; ++i) {
      res.push_back(i);
    }
  };

  if (n % 4 == 0) {
    add(1, 4);
    int m = n / 4 - 1;
    for (int i = 4; m; i += 4, --m) {
      if (i <= x and x < i + 4) continue;
      add(i, i + 4);
    }
    res.push_back(x);
  } else if (n % 4 == 1) {
    int m = n / 4;
    for (int i = 4; m; i += 4, --m) {
      if (i <= x and x < i + 4) continue;
      add(i, i + 4);
    }
    res.push_back(x);
  } else if (n % 4 == 2) {
    for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) {
      res.push_back(i);
    }
    add(1, 4);
    int m = n / 4;
    for (int i = 4; m; i += 4, --m) {
      if (i <= x and x < i + 4) continue;
      add(i, i + 4);
    }
  } else {
    for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) {
      res.push_back(i);
    }
    int m = n / 4;
    for (int i = 4; m; i += 4, --m) {
      if (i <= x and x < i + 4) continue;
      add(i, i + 4);
    }
  }

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