結果

問題 No.1355 AND OR GAME
ユーザー tarattata1tarattata1
提出日時 2021-01-17 14:35:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,607 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 92,572 KB
実行使用メモリ 5,680 KB
最終ジャッジ日時 2023-08-19 20:31:36
合計ジャッジ時間 14,000 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,384 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 55 ms
5,504 KB
testcase_36 WA -
testcase_37 AC 1 ms
4,380 KB
testcase_38 WA -
testcase_39 AC 17 ms
4,380 KB
testcase_40 AC 27 ms
4,376 KB
testcase_41 AC 55 ms
5,428 KB
testcase_42 WA -
testcase_43 AC 27 ms
4,688 KB
testcase_44 WA -
testcase_45 AC 55 ms
5,432 KB
testcase_46 AC 22 ms
4,380 KB
testcase_47 WA -
testcase_48 AC 40 ms
4,632 KB
testcase_49 WA -
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 29 ms
4,376 KB
testcase_52 WA -
testcase_53 AC 34 ms
4,388 KB
testcase_54 AC 55 ms
5,444 KB
testcase_55 AC 39 ms
5,480 KB
testcase_56 AC 39 ms
5,656 KB
testcase_57 AC 39 ms
4,740 KB
testcase_58 AC 12 ms
4,376 KB
testcase_59 AC 2 ms
4,380 KB
testcase_60 AC 37 ms
4,576 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 20 ms
4,376 KB
testcase_63 AC 55 ms
5,428 KB
testcase_64 AC 40 ms
5,528 KB
testcase_65 WA -
testcase_66 AC 14 ms
4,376 KB
testcase_67 AC 19 ms
4,376 KB
testcase_68 WA -
testcase_69 AC 1 ms
4,376 KB
testcase_70 AC 22 ms
4,376 KB
testcase_71 WA -
testcase_72 AC 55 ms
5,364 KB
testcase_73 AC 55 ms
5,368 KB
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 55 ms
5,424 KB
testcase_77 WA -
testcase_78 AC 2 ms
4,380 KB
testcase_79 AC 1 ms
4,376 KB
testcase_80 AC 55 ms
5,504 KB
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 39 ms
5,504 KB
testcase_84 AC 27 ms
4,380 KB
testcase_85 AC 76 ms
4,836 KB
testcase_86 AC 47 ms
4,376 KB
testcase_87 AC 42 ms
4,376 KB
testcase_88 AC 5 ms
4,380 KB
testcase_89 AC 4 ms
4,376 KB
testcase_90 AC 95 ms
5,420 KB
testcase_91 AC 11 ms
4,380 KB
testcase_92 AC 6 ms
4,380 KB
testcase_93 AC 69 ms
4,932 KB
testcase_94 AC 42 ms
4,380 KB
testcase_95 AC 29 ms
4,380 KB
testcase_96 AC 23 ms
4,380 KB
testcase_97 AC 5 ms
4,380 KB
testcase_98 AC 83 ms
5,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <ctime>
#pragma warning(disable:4996) 

//#define ATCODER
#ifdef ATCODER
#include <atcoder/all>
#endif

typedef long long ll;
typedef unsigned long long ull;
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;
#ifdef ATCODER
using namespace atcoder;
#endif


void solve()
{
    int n; ll x, y;
    scanf("%d%lld%lld", &n, &x, &y);
    n++;
    vector<ll> a(n);
    a[0] = x;
    int i;
    for (i = 1; i < n; i++) {
        scanf("%lld", &a[i]);
    }
    vector<int> curr(60);
    for (i = 0; i < 60; i++) {
        curr[i] = ((y & (1<<i))?1:0);
    }
    int found = 0;
    vector<int> ans(n, 1);
    for (i = n - 1; i >= 0; i--) {
        int bad0 = 0, bad1 = 0;
        vector<int> vtmp(60);
        int k;
        for (k = 0; k < 60; k++) {
            vtmp[k]= ((a[i] & (1 << k)) ? 1 : 0);
            if (vtmp[k] && curr[k] == 0) bad1 = 1;
            if (vtmp[k] == 0 && curr[k] == 1) bad0 = 1;
        }
        if (bad0 && bad1) {
            printf("-1\n"); return;
        }
        if (bad0 == 0 && bad1 == 0) {
            ans[i] = 3;
            found = 1;
            break;
        }
        if (bad1) {
            ans[i] = 1;
            vector<int> ne(60);
            for (k = 0; k < 60; k++) {
                ne[k] = 2;
                if (vtmp[k] == 1 && curr[k] == 0) ne[k] = 0;
                if (vtmp[k] == 1 && curr[k] == 1) ne[k] = 1;
            }
            curr.swap(ne);
        }
        else {
            ans[i] = 2;
            vector<int> ne(60);
            for (k = 0; k < 60; k++) {
                ne[k] = 2;
                if (vtmp[k] == 0 && curr[k] == 1) ne[k] = 1;
                if (vtmp[k] == 0 && curr[k] == 0) ne[k] = 0;
            }
            curr.swap(ne);
        }
    }
    if (found) {
        for (i = 1; i < n; i++) {
            printf("%d", ans[i]);
            if (i < n - 1) printf(" ");
            else printf("\n");
        }
    }
    else {
        printf("-1\n");
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T, t;
    cin >> T;
    for (t = 0; t < T; t++) {
        //cout << "Case #" << t + 1 << ": ";
        solve();
    }
#endif
    return 0;
}
0