結果

問題 No.1355 AND OR GAME
ユーザー DriceDrice
提出日時 2021-01-17 15:54:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,556 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 32,912 KB
実行使用メモリ 5,400 KB
最終ジャッジ日時 2023-08-19 22:16:11
合計ジャッジ時間 10,711 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 6 ms
4,380 KB
testcase_35 AC 55 ms
5,304 KB
testcase_36 AC 50 ms
5,088 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 54 ms
5,304 KB
testcase_39 AC 16 ms
4,376 KB
testcase_40 AC 27 ms
4,376 KB
testcase_41 AC 54 ms
5,308 KB
testcase_42 AC 54 ms
5,244 KB
testcase_43 AC 26 ms
4,376 KB
testcase_44 AC 9 ms
4,376 KB
testcase_45 AC 54 ms
5,348 KB
testcase_46 AC 21 ms
4,380 KB
testcase_47 AC 55 ms
5,328 KB
testcase_48 AC 39 ms
4,632 KB
testcase_49 AC 54 ms
5,336 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 28 ms
4,380 KB
testcase_52 AC 49 ms
5,016 KB
testcase_53 AC 34 ms
4,428 KB
testcase_54 AC 55 ms
5,328 KB
testcase_55 AC 39 ms
4,436 KB
testcase_56 AC 39 ms
4,432 KB
testcase_57 AC 39 ms
4,532 KB
testcase_58 AC 12 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
testcase_60 AC 36 ms
4,480 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 20 ms
4,376 KB
testcase_63 AC 55 ms
5,216 KB
testcase_64 AC 39 ms
4,428 KB
testcase_65 AC 2 ms
4,380 KB
testcase_66 AC 15 ms
4,380 KB
testcase_67 AC 19 ms
4,376 KB
testcase_68 AC 19 ms
4,380 KB
testcase_69 AC 1 ms
4,376 KB
testcase_70 AC 22 ms
4,376 KB
testcase_71 AC 54 ms
5,332 KB
testcase_72 AC 55 ms
5,336 KB
testcase_73 AC 56 ms
5,212 KB
testcase_74 AC 54 ms
5,344 KB
testcase_75 AC 54 ms
5,332 KB
testcase_76 AC 55 ms
5,324 KB
testcase_77 AC 55 ms
5,400 KB
testcase_78 AC 2 ms
4,380 KB
testcase_79 AC 2 ms
4,376 KB
testcase_80 AC 55 ms
5,308 KB
testcase_81 AC 54 ms
5,244 KB
testcase_82 AC 54 ms
5,308 KB
testcase_83 AC 39 ms
4,396 KB
testcase_84 AC 23 ms
4,376 KB
testcase_85 AC 63 ms
4,748 KB
testcase_86 AC 40 ms
4,376 KB
testcase_87 AC 35 ms
4,384 KB
testcase_88 AC 4 ms
4,376 KB
testcase_89 AC 4 ms
4,380 KB
testcase_90 AC 79 ms
5,188 KB
testcase_91 AC 8 ms
4,376 KB
testcase_92 AC 5 ms
4,380 KB
testcase_93 AC 57 ms
4,836 KB
testcase_94 AC 34 ms
4,376 KB
testcase_95 AC 24 ms
4,376 KB
testcase_96 AC 19 ms
4,380 KB
testcase_97 AC 4 ms
4,380 KB
testcase_98 AC 69 ms
5,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
long long a[200005];
int p[200005];
long long bit[70];
long long have[70];
//0: must 0
//1: must 1
//2: ok

void factor(long long u,int n,long long bit[]){
    for(int i = 1; i <= n; i++){
        bit[i] = u%2;
        u /= 2;
    }
}

int main(){
    int n; long long x,y;
    scanf("%d%lld%lld",&n,&x,&y);
    a[1] = x;
    n++;
    for(int i = 2; i <= n; i++) scanf("%lld",&a[i]);
    int len = 60;
    factor(y,len,bit);
    int find = -1;
    for(int i = n; i >= 1; i--){
        int cnt0 = 0, cnt1 = 0;
        factor(a[i],len,have);
        for(int j = 1; j <= len; j++){
            if(bit[j]!=2 && bit[j]!=have[j]){
                if(have[j]) cnt1++;
                else cnt0++;
            }
        }
        if(!cnt0 && !cnt1){
            find = i;
            p[i] = 3;
            break;
        }
        else{
            if(cnt0 && cnt1) break;
            else if(cnt0){
                p[i] = 2;
                for(int j = 1; j <= len; j++){
                    if(have[j]){
                        if(bit[j]==1) bit[j] = 2;
                    }
                }
            }
            else{
                p[i] = 1;
                for(int j = 1; j <= len; j++){
                    if(!have[j]){
                        if(bit[j]==0) bit[j] = 2;
                    }
                }
            }
        }
    }
    if(find==-1) printf("-1\n");
    else{
        for(int i = 1; i < find; i++) p[i] = 2;
        for(int i = 2; i <= n; i++) printf("%d ",p[i]);
        printf("\n");
    }
    return 0;
}
0