結果

問題 No.1355 AND OR GAME
ユーザー chocoruskchocorusk
提出日時 2021-01-17 15:37:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 1,920 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 129,628 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 04:59:15
合計ジャッジ時間 14,665 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 17 ms
6,944 KB
testcase_35 AC 154 ms
6,948 KB
testcase_36 AC 140 ms
6,944 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 155 ms
6,944 KB
testcase_39 AC 56 ms
6,940 KB
testcase_40 AC 75 ms
6,940 KB
testcase_41 AC 155 ms
6,940 KB
testcase_42 AC 156 ms
6,944 KB
testcase_43 AC 90 ms
6,940 KB
testcase_44 AC 24 ms
6,944 KB
testcase_45 AC 153 ms
6,940 KB
testcase_46 AC 59 ms
6,944 KB
testcase_47 AC 155 ms
6,940 KB
testcase_48 AC 110 ms
6,940 KB
testcase_49 AC 155 ms
6,944 KB
testcase_50 AC 2 ms
6,944 KB
testcase_51 AC 80 ms
6,944 KB
testcase_52 AC 139 ms
6,944 KB
testcase_53 AC 96 ms
6,944 KB
testcase_54 AC 155 ms
6,940 KB
testcase_55 AC 134 ms
6,940 KB
testcase_56 AC 135 ms
6,940 KB
testcase_57 AC 107 ms
6,940 KB
testcase_58 AC 31 ms
6,940 KB
testcase_59 AC 2 ms
6,944 KB
testcase_60 AC 102 ms
6,940 KB
testcase_61 AC 2 ms
6,944 KB
testcase_62 AC 67 ms
6,940 KB
testcase_63 AC 154 ms
6,944 KB
testcase_64 AC 136 ms
6,940 KB
testcase_65 AC 4 ms
6,944 KB
testcase_66 AC 47 ms
6,940 KB
testcase_67 AC 50 ms
6,944 KB
testcase_68 AC 50 ms
6,940 KB
testcase_69 AC 2 ms
6,944 KB
testcase_70 AC 58 ms
6,940 KB
testcase_71 AC 154 ms
6,940 KB
testcase_72 AC 155 ms
6,940 KB
testcase_73 AC 156 ms
6,940 KB
testcase_74 AC 155 ms
6,944 KB
testcase_75 AC 154 ms
6,940 KB
testcase_76 AC 154 ms
6,940 KB
testcase_77 AC 155 ms
6,940 KB
testcase_78 AC 2 ms
6,940 KB
testcase_79 AC 2 ms
6,940 KB
testcase_80 AC 155 ms
6,940 KB
testcase_81 AC 154 ms
6,944 KB
testcase_82 AC 154 ms
6,940 KB
testcase_83 AC 135 ms
6,940 KB
testcase_84 AC 35 ms
6,940 KB
testcase_85 AC 95 ms
6,944 KB
testcase_86 AC 60 ms
6,940 KB
testcase_87 AC 54 ms
6,940 KB
testcase_88 AC 5 ms
6,940 KB
testcase_89 AC 5 ms
6,940 KB
testcase_90 AC 120 ms
6,940 KB
testcase_91 AC 14 ms
6,944 KB
testcase_92 AC 7 ms
6,944 KB
testcase_93 AC 89 ms
6,944 KB
testcase_94 AC 52 ms
6,940 KB
testcase_95 AC 37 ms
6,940 KB
testcase_96 AC 30 ms
6,940 KB
testcase_97 AC 6 ms
6,940 KB
testcase_98 AC 106 ms
6,944 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