結果

問題 No.1355 AND OR GAME
ユーザー maguromaguro
提出日時 2021-01-12 22:26:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,057 bytes
コンパイル時間 3,562 ms
コンパイル使用メモリ 208,540 KB
実行使用メモリ 58,816 KB
最終ジャッジ日時 2024-05-01 08:52:27
合計ジャッジ時間 25,556 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 4 ms
6,944 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 2 ms
6,940 KB
testcase_13 RE -
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 3 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 3 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 24 ms
8,576 KB
testcase_35 AC 226 ms
58,776 KB
testcase_36 AC 209 ms
54,248 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 227 ms
58,676 KB
testcase_39 AC 83 ms
25,472 KB
testcase_40 AC 110 ms
30,080 KB
testcase_41 AC 224 ms
58,680 KB
testcase_42 RE -
testcase_43 AC 138 ms
39,808 KB
testcase_44 AC 34 ms
11,392 KB
testcase_45 AC 228 ms
58,800 KB
testcase_46 AC 84 ms
23,680 KB
testcase_47 AC 226 ms
58,752 KB
testcase_48 AC 164 ms
42,752 KB
testcase_49 AC 227 ms
58,680 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 114 ms
31,232 KB
testcase_52 AC 202 ms
52,352 KB
testcase_53 AC 139 ms
37,120 KB
testcase_54 AC 228 ms
58,672 KB
testcase_55 AC 209 ms
58,684 KB
testcase_56 AC 209 ms
58,816 KB
testcase_57 AC 158 ms
41,728 KB
testcase_58 AC 44 ms
13,824 KB
testcase_59 AC 2 ms
5,376 KB
testcase_60 AC 151 ms
40,064 KB
testcase_61 AC 2 ms
5,376 KB
testcase_62 AC 103 ms
30,464 KB
testcase_63 AC 228 ms
58,752 KB
testcase_64 AC 208 ms
58,624 KB
testcase_65 AC 3 ms
5,376 KB
testcase_66 AC 71 ms
21,888 KB
testcase_67 AC 72 ms
20,736 KB
testcase_68 AC 72 ms
20,480 KB
testcase_69 AC 2 ms
5,376 KB
testcase_70 AC 86 ms
23,936 KB
testcase_71 AC 226 ms
58,660 KB
testcase_72 AC 226 ms
58,748 KB
testcase_73 AC 227 ms
58,752 KB
testcase_74 AC 229 ms
58,700 KB
testcase_75 AC 227 ms
58,688 KB
testcase_76 AC 225 ms
58,624 KB
testcase_77 AC 228 ms
58,624 KB
testcase_78 AC 2 ms
5,376 KB
testcase_79 AC 2 ms
5,376 KB
testcase_80 AC 229 ms
58,740 KB
testcase_81 AC 228 ms
58,752 KB
testcase_82 AC 227 ms
58,624 KB
testcase_83 AC 209 ms
58,624 KB
testcase_84 RE -
testcase_85 RE -
testcase_86 RE -
testcase_87 RE -
testcase_88 RE -
testcase_89 RE -
testcase_90 RE -
testcase_91 RE -
testcase_92 RE -
testcase_93 RE -
testcase_94 RE -
testcase_95 RE -
testcase_96 RE -
testcase_97 RE -
testcase_98 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000030;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

template<class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mod(ll val, ll M) {
    val = val % M;
    if(val < 0) {
        val += M;
    }
    return val;
}

template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    ll X,Y;
    cin >> N >> X >> Y;
    assert(1 <= N && N <= 200000);
    assert(1ll <= X && X <= 1000000000000000000ll);
    assert(1ll <= Y && Y <= 1000000000000000000ll);
    vector<vector<int>> vec(N,vector<int>(62));
    for(int i = 0;i < N;i++) {
        ll A;
        cin >> A;
        assert(1ll <= A && A <= 1000000000000000000ll);
        for(int j = 0;j < 62;j++) {
            vec.at(i).at(j) = A % 2;
            A /= 2;
        }
    }
    reverse(vec.begin(),vec.end());
    vector<int> now(62);
    for(int i = 0;i < 62;i++) {
        now.at(i) = Y % 2;
        Y /= 2;
    }
    bool ret = false;
    vector<int> ret2(N,1);
    for(int i = 0;i < N;i++) {
        bool cnt1 = false;
        bool cnt2 = false;
        for(int j = 0;j < 62;j++) {
            if(now.at(j) == 1 && vec.at(i).at(j) == 0) {
                cnt1 = true;
            }
            else if(now.at(j) == 0 && vec.at(i).at(j) == 1) {
                cnt2 = true;
            }
        }
        if(cnt1 && cnt2) {
            break;
        }
        else if(!(cnt1 || cnt2)) {
            ret = true;
            ret2.at(i) = 3;
            break;
        }
        else if(cnt1) {
            ret2.at(i) = 2;
            for(int j = 0;j < 62;j++) {
                if(now.at(j) == 1) {
                    if(vec.at(i).at(j) == 1) now.at(j) = 2;
                }
            }
        }
        else {
            ret2.at(i) = 1;
            for(int j = 0;j < 62;j++) {
                if(now.at(j) == 0) {
                    if(vec.at(i).at(j) == 0) now.at(j) = 2;
                }
            }
        }

        if(i == N - 1) {
            bool cnt3 = true;
            for(int j = 0;j < 62;j++) {
                if(now.at(j) != 2 && now.at(j) != X % 2) {
                    cnt3 = false;
                }
                X /= 2;
            }
            if(cnt3) ret = true;
        }
    }
    
    if(!ret) cout << -1 << endl;
    else {
        reverse(ret2.begin(),ret2.end());
        for(int i = 0;i < N;i++) {
            cout << ret2.at(i) << " ";
        }
        cout << endl;
    }
}
0