結果
| 問題 | No.1355 AND OR GAME | 
| コンテスト | |
| ユーザー |  tarattata1 | 
| 提出日時 | 2021-01-17 14:26:29 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,485 bytes | 
| コンパイル時間 | 867 ms | 
| コンパイル使用メモリ | 94,540 KB | 
| 実行使用メモリ | 5,760 KB | 
| 最終ジャッジ日時 | 2024-11-29 15:49:59 | 
| 合計ジャッジ時間 | 18,008 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 WA * 1 | 
| other | AC * 44 WA * 51 | 
ソースコード
#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;
            }
            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;
            }
            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;
}
            
            
            
        