結果

問題 No.1355 AND OR GAME
ユーザー DriceDrice
提出日時 2021-01-17 15:54:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 1,556 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 33,024 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-07 05:20:14
合計ジャッジ時間 9,238 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 1 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,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 7 ms
6,940 KB
testcase_35 AC 55 ms
6,944 KB
testcase_36 AC 50 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 56 ms
6,940 KB
testcase_39 AC 16 ms
6,940 KB
testcase_40 AC 27 ms
6,944 KB
testcase_41 AC 55 ms
6,940 KB
testcase_42 AC 55 ms
6,944 KB
testcase_43 AC 26 ms
6,940 KB
testcase_44 AC 10 ms
6,940 KB
testcase_45 AC 56 ms
6,940 KB
testcase_46 AC 22 ms
6,944 KB
testcase_47 AC 56 ms
6,940 KB
testcase_48 AC 40 ms
6,944 KB
testcase_49 AC 54 ms
6,944 KB
testcase_50 AC 2 ms
6,940 KB
testcase_51 AC 28 ms
6,944 KB
testcase_52 AC 50 ms
6,944 KB
testcase_53 AC 35 ms
6,940 KB
testcase_54 AC 57 ms
6,940 KB
testcase_55 AC 38 ms
6,940 KB
testcase_56 AC 39 ms
6,940 KB
testcase_57 AC 39 ms
6,940 KB
testcase_58 AC 12 ms
6,944 KB
testcase_59 AC 2 ms
6,940 KB
testcase_60 AC 38 ms
6,940 KB
testcase_61 AC 2 ms
6,944 KB
testcase_62 AC 21 ms
6,944 KB
testcase_63 AC 57 ms
6,944 KB
testcase_64 AC 38 ms
6,940 KB
testcase_65 AC 2 ms
6,944 KB
testcase_66 AC 14 ms
6,944 KB
testcase_67 AC 20 ms
6,944 KB
testcase_68 AC 18 ms
6,940 KB
testcase_69 AC 2 ms
6,944 KB
testcase_70 AC 22 ms
6,940 KB
testcase_71 AC 56 ms
6,940 KB
testcase_72 AC 55 ms
6,944 KB
testcase_73 AC 56 ms
6,940 KB
testcase_74 AC 57 ms
6,944 KB
testcase_75 AC 56 ms
6,944 KB
testcase_76 AC 56 ms
6,940 KB
testcase_77 AC 54 ms
6,944 KB
testcase_78 AC 2 ms
6,940 KB
testcase_79 AC 2 ms
6,944 KB
testcase_80 AC 58 ms
6,944 KB
testcase_81 AC 55 ms
6,940 KB
testcase_82 AC 56 ms
6,944 KB
testcase_83 AC 38 ms
6,944 KB
testcase_84 AC 26 ms
6,940 KB
testcase_85 AC 74 ms
6,940 KB
testcase_86 AC 47 ms
6,944 KB
testcase_87 AC 40 ms
6,940 KB
testcase_88 AC 5 ms
6,944 KB
testcase_89 AC 4 ms
6,940 KB
testcase_90 AC 91 ms
6,944 KB
testcase_91 AC 10 ms
6,940 KB
testcase_92 AC 6 ms
6,940 KB
testcase_93 AC 65 ms
6,940 KB
testcase_94 AC 38 ms
6,944 KB
testcase_95 AC 28 ms
6,944 KB
testcase_96 AC 22 ms
6,944 KB
testcase_97 AC 5 ms
6,940 KB
testcase_98 AC 78 ms
6,940 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