結果

問題 No.1355 AND OR GAME
ユーザー titiatitia
提出日時 2021-09-02 01:02:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 405 ms / 2,000 ms
コード長 1,105 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 87,320 KB
実行使用メモリ 124,588 KB
最終ジャッジ日時 2023-08-19 08:13:41
合計ジャッジ時間 26,091 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,172 KB
testcase_01 AC 70 ms
71,236 KB
testcase_02 AC 78 ms
76,820 KB
testcase_03 AC 76 ms
76,536 KB
testcase_04 AC 75 ms
76,528 KB
testcase_05 AC 68 ms
71,232 KB
testcase_06 AC 76 ms
76,216 KB
testcase_07 AC 76 ms
76,220 KB
testcase_08 AC 76 ms
76,396 KB
testcase_09 AC 70 ms
75,328 KB
testcase_10 AC 68 ms
71,228 KB
testcase_11 AC 67 ms
71,268 KB
testcase_12 AC 67 ms
71,184 KB
testcase_13 AC 66 ms
71,636 KB
testcase_14 AC 68 ms
71,268 KB
testcase_15 AC 68 ms
71,304 KB
testcase_16 AC 67 ms
71,512 KB
testcase_17 AC 62 ms
71,408 KB
testcase_18 AC 67 ms
71,448 KB
testcase_19 AC 64 ms
71,088 KB
testcase_20 AC 66 ms
71,308 KB
testcase_21 AC 65 ms
71,172 KB
testcase_22 AC 66 ms
71,272 KB
testcase_23 AC 65 ms
71,304 KB
testcase_24 AC 65 ms
71,636 KB
testcase_25 AC 66 ms
71,308 KB
testcase_26 AC 68 ms
71,432 KB
testcase_27 AC 70 ms
71,412 KB
testcase_28 AC 68 ms
71,220 KB
testcase_29 AC 69 ms
71,200 KB
testcase_30 AC 70 ms
71,540 KB
testcase_31 AC 67 ms
71,192 KB
testcase_32 AC 66 ms
71,428 KB
testcase_33 AC 66 ms
71,444 KB
testcase_34 AC 80 ms
78,696 KB
testcase_35 AC 164 ms
123,508 KB
testcase_36 AC 153 ms
117,880 KB
testcase_37 AC 70 ms
71,040 KB
testcase_38 AC 164 ms
124,324 KB
testcase_39 AC 93 ms
87,212 KB
testcase_40 AC 111 ms
96,036 KB
testcase_41 AC 155 ms
124,272 KB
testcase_42 AC 156 ms
124,536 KB
testcase_43 AC 105 ms
92,932 KB
testcase_44 AC 85 ms
81,164 KB
testcase_45 AC 151 ms
124,344 KB
testcase_46 AC 106 ms
91,604 KB
testcase_47 AC 157 ms
124,324 KB
testcase_48 AC 131 ms
104,764 KB
testcase_49 AC 148 ms
124,564 KB
testcase_50 AC 65 ms
71,372 KB
testcase_51 AC 111 ms
96,732 KB
testcase_52 AC 143 ms
116,252 KB
testcase_53 AC 123 ms
97,984 KB
testcase_54 AC 151 ms
124,204 KB
testcase_55 AC 123 ms
107,000 KB
testcase_56 AC 119 ms
107,292 KB
testcase_57 AC 131 ms
103,148 KB
testcase_58 AC 88 ms
83,076 KB
testcase_59 AC 65 ms
71,420 KB
testcase_60 AC 132 ms
99,924 KB
testcase_61 AC 67 ms
71,220 KB
testcase_62 AC 94 ms
91,424 KB
testcase_63 AC 153 ms
124,412 KB
testcase_64 AC 120 ms
107,152 KB
testcase_65 AC 80 ms
76,108 KB
testcase_66 AC 86 ms
85,392 KB
testcase_67 AC 100 ms
89,072 KB
testcase_68 AC 98 ms
88,824 KB
testcase_69 AC 67 ms
71,044 KB
testcase_70 AC 104 ms
91,900 KB
testcase_71 AC 153 ms
124,192 KB
testcase_72 AC 154 ms
124,460 KB
testcase_73 AC 153 ms
124,448 KB
testcase_74 AC 156 ms
124,588 KB
testcase_75 AC 157 ms
124,432 KB
testcase_76 AC 158 ms
124,416 KB
testcase_77 AC 156 ms
124,124 KB
testcase_78 AC 66 ms
71,088 KB
testcase_79 AC 71 ms
71,180 KB
testcase_80 AC 151 ms
124,564 KB
testcase_81 AC 157 ms
124,236 KB
testcase_82 AC 156 ms
124,236 KB
testcase_83 AC 121 ms
106,952 KB
testcase_84 AC 180 ms
84,476 KB
testcase_85 AC 334 ms
99,808 KB
testcase_86 AC 256 ms
90,168 KB
testcase_87 AC 239 ms
88,524 KB
testcase_88 AC 101 ms
77,152 KB
testcase_89 AC 109 ms
77,608 KB
testcase_90 AC 377 ms
104,348 KB
testcase_91 AC 124 ms
78,516 KB
testcase_92 AC 118 ms
77,404 KB
testcase_93 AC 350 ms
99,756 KB
testcase_94 AC 240 ms
90,212 KB
testcase_95 AC 191 ms
85,972 KB
testcase_96 AC 166 ms
83,580 KB
testcase_97 AC 114 ms
77,052 KB
testcase_98 AC 405 ms
101,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,X,Y=map(int,input().split())
A=list(map(int,input().split()))

initY=Y

P=[]

Y=list(map(int,list(bin(Y)[2:].zfill(64)[::-1])))


for i in range(N-1,-1,-1):
    #print(i,Y)
    S=0
    T=0
    for j in range(64):
        if (1<<j) & A[i]!=0 and Y[j] == 0:
            S=1
        if (1<<j) & A[i]==0 and Y[j] == 1:
            T=1

    if S==0 and T==0:
        P.append(3)
        P+=[1]*(N-len(P))
        print(*P[::-1])
        exit()
    elif S==1 and T==1:
        print(-1)
        exit()
    elif S==1:
        P.append(1)
        for j in range(64):
            if Y[j]==0:
                if (1<<j) & A[i]!=0:
                    True
                else:
                    Y[j]=-1
    else:
        P.append(2)
        for j in range(64):
            if Y[j]==1:
                if (1<<j) & A[i]==0:
                    True
                else:
                    Y[j]=-1

P=P[::-1]
for i in range(N):
    if P[i]==1:
        X&=A[i]
    elif P[i]==2:
        X|=A[i]
    else:
        X=A[i]

if X==initY:
    print(*P)
else:
    print(-1)

    
0