結果
| 問題 | 
                            No.862 XORでX
                             | 
                    
| コンテスト | |
| ユーザー | 
                             risujiroh
                         | 
                    
| 提出日時 | 2019-08-09 22:57:09 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,667 bytes | 
| コンパイル時間 | 1,795 ms | 
| コンパイル使用メモリ | 170,432 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-19 15:21:05 | 
| 合計ジャッジ時間 | 6,958 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 RE * 1 | 
| other | AC * 14 WA * 3 RE * 11 | 
ソースコード
#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;
  }
  V<> res;
  auto add = [&](int l, int r) -> void {
    for (int i = l; i < r; ++i) {
      res.push_back(i);
    }
  };
  assert(n % 4 <= 1);
  if (n % 4 == 0) {
    if (x < 4) {
      res.push_back(16 | x);
      res.push_back(20);
      res.push_back(24);
      res.push_back(28);
    } 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.push_back(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.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) {
      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.push_back(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';
  }
}
            
            
            
        
            
risujiroh