結果
問題 |
No.862 XORでX
|
ユーザー |
![]() |
提出日時 | 2019-08-09 23:10:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,766 bytes |
コンパイル時間 | 1,658 ms |
コンパイル使用メモリ | 161,328 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-19 15:39:51 |
合計ジャッジ時間 | 12,344 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 2 RE * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0; i<int(n); i++) #define FOR(i,m,n) for(int i=int(m); i<int(n); i++) #define ALL(obj) (obj).begin(),(obj).end() #define VI vector<int> #define VLL vector<long long> #define VVI vector<vector<int>> #define VVLL vector<vector<long long>> #define VC vector<char> #define VS vector<string> #define VVC vector<vector<char>> #define VB vector<bool> #define VVB vector<vector<bool>> #define fore(i,a) for(auto &i:a) typedef pair <int, int> P; template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1 << 30; const ll INFL = 1LL << 60; const ll mod = 1000000007; int main() { int n, x; cin >> n >> x; VI v(20, 0); int sum = 0; REP(i, 20) { if ((1 << i)&x) { v[i]++; sum++; } } if (n == 1) { cout << x << endl; return 0; } if (n == 2) { if (x == 1) { cout << 2 << endl; x ^= 2; cout << x << endl; } else { cout << 1 << endl; x ^= 1; cout << x << endl; } return 0; } int m = n; if (m % 2 == 0)m--; m -= 2; int a = 0; FOR(i, 1, m + 1) { cout << i << endl; a ^= i; n--; } x ^= a; if (n == 2) { FOR(i, m + 1, 100005) { int j = x ^ i; if (m < j&&j <= 100005) { cout << j << endl; cout << i << endl; return 0; } } } if (n == 3) { FOR(i, m + 1, 100005) { FOR(j, m + 1, 100005) { if (i == j)continue; int k = x ^ i; k ^= j; if (k == i || k == j)continue; if (m < k&&k <= 100005) { cout << i << endl; cout << j << endl; cout << k << endl; return 0; } } } } assert(n == 0); }