結果

問題 No.1298 OR XOR
ユーザー sapphire__15sapphire__15
提出日時 2020-11-27 23:43:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,913 bytes
コンパイル時間 1,074 ms
コンパイル使用メモリ 113,636 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-09 21:21:59
合計ジャッジ時間 2,034 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <cassert>
#include <stack>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, ss) for (int i = (ss);i < (int)( n ); i++)
#define all(l) l.begin(), l.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &l, const T b) {
    if (l < b) {
        l = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &l, const T b) {
    if (l > b) {
        l = b;
        return true;
    }
    return false;
}

# ifdef LOCAL_DEBUG
template<typename T>
void vdeb(const std::vector<T> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(const std::vector<std::vector<T>> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}
# endif

using namespace std;

int main() {
    ll n; cin >> n;
    if(__builtin_popcount(n) < 2) {
        cout << -1 MM -1 MM -1 << endl;
        return 0;
    }
    ll a = n, b = n, c = n;
    int cnt = 0;
    rip(i,30, 0) {
        if((1 << i)&n) {
            if(cnt == 0) {
                a ^= 1<< i;
                cnt++;
            }
            else if(cnt == 1) {
                b ^= 1 << i;
            }
            else {
                c ^= 1 << i;
            }
        }
    }
    cout << a MM b MM c << endl;
}
0