結果

問題 No.1355 AND OR GAME
ユーザー maguromaguro
提出日時 2021-01-12 22:03:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,569 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 208,020 KB
実行使用メモリ 58,840 KB
最終ジャッジ日時 2024-05-01 08:29:07
合計ジャッジ時間 20,074 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 25 ms
8,576 KB
testcase_35 AC 237 ms
58,624 KB
testcase_36 AC 216 ms
54,308 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 237 ms
58,752 KB
testcase_39 AC 88 ms
25,344 KB
testcase_40 AC 114 ms
29,952 KB
testcase_41 AC 236 ms
58,752 KB
testcase_42 AC 238 ms
58,668 KB
testcase_43 AC 144 ms
39,936 KB
testcase_44 AC 37 ms
11,392 KB
testcase_45 AC 246 ms
58,752 KB
testcase_46 AC 88 ms
23,680 KB
testcase_47 AC 239 ms
58,752 KB
testcase_48 AC 169 ms
42,740 KB
testcase_49 AC 238 ms
58,720 KB
testcase_50 WA -
testcase_51 AC 120 ms
31,104 KB
testcase_52 AC 210 ms
52,352 KB
testcase_53 AC 143 ms
37,044 KB
testcase_54 AC 238 ms
58,752 KB
testcase_55 AC 222 ms
58,648 KB
testcase_56 AC 218 ms
58,752 KB
testcase_57 AC 164 ms
41,728 KB
testcase_58 AC 47 ms
13,824 KB
testcase_59 AC 2 ms
5,376 KB
testcase_60 AC 156 ms
39,936 KB
testcase_61 AC 2 ms
5,376 KB
testcase_62 AC 109 ms
30,336 KB
testcase_63 AC 237 ms
58,672 KB
testcase_64 AC 220 ms
58,752 KB
testcase_65 AC 3 ms
5,376 KB
testcase_66 AC 75 ms
21,888 KB
testcase_67 AC 76 ms
20,864 KB
testcase_68 AC 76 ms
20,480 KB
testcase_69 AC 2 ms
5,376 KB
testcase_70 AC 90 ms
23,936 KB
testcase_71 AC 241 ms
58,624 KB
testcase_72 AC 238 ms
58,752 KB
testcase_73 AC 236 ms
58,624 KB
testcase_74 AC 237 ms
58,624 KB
testcase_75 AC 239 ms
58,700 KB
testcase_76 AC 239 ms
58,660 KB
testcase_77 AC 237 ms
58,752 KB
testcase_78 AC 2 ms
5,376 KB
testcase_79 AC 2 ms
5,376 KB
testcase_80 AC 238 ms
58,752 KB
testcase_81 AC 239 ms
58,744 KB
testcase_82 AC 238 ms
58,840 KB
testcase_83 AC 220 ms
58,624 KB
testcase_84 AC 66 ms
20,352 KB
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 AC 9 ms
5,376 KB
testcase_89 WA -
testcase_90 WA -
testcase_91 AC 24 ms
9,344 KB
testcase_92 WA -
testcase_93 AC 172 ms
48,288 KB
testcase_94 AC 100 ms
29,696 KB
testcase_95 AC 71 ms
22,272 KB
testcase_96 AC 55 ms
17,664 KB
testcase_97 AC 11 ms
5,760 KB
testcase_98 AC 208 ms
58,560 KB
権限があれば一括ダウンロードができます

ソースコード

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;
    vector<vector<int>> vec(N,vector<int>(62));
    for(int i = 0;i < N;i++) {
        ll A;
        cin >> A;
        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(!ret) cout << -1 << endl;
    else {
        reverse(ret2.begin(),ret2.end());
        for(int i = 0;i < N;i++) {
            cout << ret2.at(i) << " ";
        }
        cout << endl;
    }
}
0