結果

問題 No.1298 OR XOR
ユーザー altair_kyoproaltair_kyopro
提出日時 2020-11-27 21:39:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,211 bytes
コンパイル時間 1,515 ms
コンパイル使用メモリ 168,024 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-26 11:59:55
合計ジャッジ時間 3,075 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 from main.cpp:2:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:56:37:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized]
  202 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:42:12: note: 'c' was declared here
   42 |     ll a,b,c;
      |            ^
main.cpp:49:22: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
   49 |             if (x) b += t;
      |                    ~~^~~~
main.cpp:42:10: note: 'b' was declared here
   42 |     ll a,b,c;
      |          ^
main.cpp:48:15: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
   48 |             a += t;
      |             ~~^~~~
main.cpp:42:8: note: 'a' was declared here
   42 |     ll a,b,c;
      |        ^

ソースコード

diff #

#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

template<class T> bool chmin(T &a, T b) {if(a>b){a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b){a=b;return 1;}return 0;}
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    cin >> n;

    bitset<32> bit(n);

    ll count = 0;

    for (ll i = 0; i < 31; i++){
        if (bit.test(i)){
            count++;
        }
    }

    if (count <= 1){
        cout << -1 << " " << -1 << " " << -1 << endl;
        return 0;
    }

    ll a,b,c;
    ll t = 1;
    bool x = true;

    for (ll i = 0; i < 31; i++){
        if (bit.test(i)){
            a += t;
            if (x) b += t;
            else c += t;
            x = !x;
        }
        t *= 2;
    }

    cout << a << " " << b << " " << c << endl;
}
0