結果

問題 No.1355 AND OR GAME
ユーザー chocoruskchocorusk
提出日時 2021-01-17 15:37:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 1,920 bytes
コンパイル時間 1,458 ms
コンパイル使用メモリ 128,056 KB
実行使用メモリ 5,764 KB
最終ジャッジ日時 2023-08-19 21:54:03
合計ジャッジ時間 15,331 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,388 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,384 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 16 ms
5,636 KB
testcase_35 AC 144 ms
5,664 KB
testcase_36 AC 132 ms
5,484 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 144 ms
5,712 KB
testcase_39 AC 51 ms
4,380 KB
testcase_40 AC 69 ms
4,500 KB
testcase_41 AC 143 ms
5,624 KB
testcase_42 AC 143 ms
5,708 KB
testcase_43 AC 84 ms
4,544 KB
testcase_44 AC 22 ms
4,380 KB
testcase_45 AC 143 ms
5,664 KB
testcase_46 AC 54 ms
4,380 KB
testcase_47 AC 144 ms
5,760 KB
testcase_48 AC 103 ms
5,120 KB
testcase_49 AC 143 ms
5,700 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 73 ms
4,628 KB
testcase_52 AC 128 ms
5,400 KB
testcase_53 AC 89 ms
4,744 KB
testcase_54 AC 145 ms
5,640 KB
testcase_55 AC 127 ms
5,072 KB
testcase_56 AC 127 ms
5,116 KB
testcase_57 AC 100 ms
4,940 KB
testcase_58 AC 29 ms
4,380 KB
testcase_59 AC 2 ms
4,380 KB
testcase_60 AC 95 ms
4,932 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 63 ms
4,384 KB
testcase_63 AC 143 ms
5,712 KB
testcase_64 AC 126 ms
5,184 KB
testcase_65 AC 2 ms
4,380 KB
testcase_66 AC 44 ms
4,376 KB
testcase_67 AC 46 ms
4,376 KB
testcase_68 AC 46 ms
4,376 KB
testcase_69 AC 2 ms
4,380 KB
testcase_70 AC 54 ms
4,380 KB
testcase_71 AC 143 ms
5,648 KB
testcase_72 AC 143 ms
5,660 KB
testcase_73 AC 144 ms
5,760 KB
testcase_74 AC 143 ms
5,764 KB
testcase_75 AC 144 ms
5,648 KB
testcase_76 AC 143 ms
5,696 KB
testcase_77 AC 143 ms
5,696 KB
testcase_78 AC 1 ms
4,376 KB
testcase_79 AC 2 ms
4,380 KB
testcase_80 AC 147 ms
5,720 KB
testcase_81 AC 143 ms
5,656 KB
testcase_82 AC 143 ms
5,656 KB
testcase_83 AC 127 ms
4,956 KB
testcase_84 AC 33 ms
4,376 KB
testcase_85 AC 89 ms
5,072 KB
testcase_86 AC 56 ms
4,608 KB
testcase_87 AC 50 ms
4,500 KB
testcase_88 AC 5 ms
4,376 KB
testcase_89 AC 4 ms
4,380 KB
testcase_90 AC 113 ms
5,624 KB
testcase_91 AC 13 ms
4,376 KB
testcase_92 AC 7 ms
4,380 KB
testcase_93 AC 85 ms
5,284 KB
testcase_94 AC 49 ms
4,568 KB
testcase_95 AC 36 ms
4,380 KB
testcase_96 AC 29 ms
4,376 KB
testcase_97 AC 6 ms
4,380 KB
testcase_98 AC 102 ms
5,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; ll x, y; cin>>n>>x>>y;
    ll a[200020];
    for(int i=0; i<n; i++) cin>>a[i];
    int b[61]={};
    for(int i=0; i<60; i++) if(y&(1ll<<i)) b[i]=1;
    int p[200020];
    bool ok=0;
    for(int i=n-1; i>=0; i--){
        ll yi=0, ai=0;
        for(int j=0; j<60; j++){
            if(b[j]==1) yi^=(1ll<<j);
            if(b[j]!=-1 && (a[i]&(1ll<<j))) ai^=(1ll<<j);
        }
        if(ai==yi){
            for(int j=0; j<=i; j++) p[j]=3;
            ok=1;
            break;
        }
        if((yi&ai)==ai){
            p[i]=2;
            for(int j=0; j<60; j++){
                if(b[j]==1 && (a[i]&(1ll<<j))){
                    b[j]=-1;
                }
            }
        }else if((yi&ai)==yi){
            p[i]=1;
            for(int j=0; j<60; j++){
                if(b[j]==0 && !(a[i]&(1ll<<j))){
                    b[j]=-1;
                }
            }
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    if(!ok){
        for(int i=0; i<60; i++){
            if(b[i]==1 && !(x&(1ll<<i))){
                cout<<-1<<endl;
                return 0;
            }
            if(b[i]==0 && x&(1ll<<i)){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    for(int i=0; i<n; i++){
        cout<<p[i];
        if(i<n-1) cout<<" ";
    }
    cout<<endl;
    return 0;
}
0