結果
問題 | No.1355 AND OR GAME |
ユーザー | αmusement |
提出日時 | 2021-01-17 15:16:04 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 3,570 bytes |
コンパイル時間 | 3,181 ms |
コンパイル使用メモリ | 222,884 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-11-29 17:27:07 |
合計ジャッジ時間 | 12,047 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 3 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 2 ms
5,248 KB |
testcase_09 | AC | 2 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 2 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 2 ms
5,248 KB |
testcase_14 | AC | 2 ms
5,248 KB |
testcase_15 | AC | 2 ms
5,248 KB |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 2 ms
5,248 KB |
testcase_18 | AC | 2 ms
5,248 KB |
testcase_19 | AC | 2 ms
5,248 KB |
testcase_20 | AC | 2 ms
5,248 KB |
testcase_21 | AC | 2 ms
5,248 KB |
testcase_22 | AC | 2 ms
5,248 KB |
testcase_23 | AC | 2 ms
5,248 KB |
testcase_24 | AC | 2 ms
5,248 KB |
testcase_25 | AC | 2 ms
5,248 KB |
testcase_26 | AC | 2 ms
5,248 KB |
testcase_27 | AC | 2 ms
5,248 KB |
testcase_28 | AC | 2 ms
5,248 KB |
testcase_29 | AC | 2 ms
5,248 KB |
testcase_30 | AC | 2 ms
5,248 KB |
testcase_31 | AC | 2 ms
5,248 KB |
testcase_32 | AC | 2 ms
5,248 KB |
testcase_33 | AC | 2 ms
5,248 KB |
testcase_34 | AC | 8 ms
5,248 KB |
testcase_35 | AC | 58 ms
6,400 KB |
testcase_36 | AC | 53 ms
6,272 KB |
testcase_37 | AC | 2 ms
5,248 KB |
testcase_38 | AC | 58 ms
6,528 KB |
testcase_39 | AC | 16 ms
5,248 KB |
testcase_40 | AC | 29 ms
5,248 KB |
testcase_41 | AC | 57 ms
6,528 KB |
testcase_42 | AC | 58 ms
6,528 KB |
testcase_43 | AC | 26 ms
5,248 KB |
testcase_44 | AC | 10 ms
5,248 KB |
testcase_45 | AC | 57 ms
6,400 KB |
testcase_46 | AC | 22 ms
5,248 KB |
testcase_47 | AC | 58 ms
6,528 KB |
testcase_48 | AC | 42 ms
5,760 KB |
testcase_49 | AC | 58 ms
6,528 KB |
testcase_50 | AC | 2 ms
5,248 KB |
testcase_51 | AC | 30 ms
5,248 KB |
testcase_52 | AC | 51 ms
6,272 KB |
testcase_53 | AC | 36 ms
5,248 KB |
testcase_54 | AC | 58 ms
6,528 KB |
testcase_55 | AC | 37 ms
6,400 KB |
testcase_56 | AC | 37 ms
6,400 KB |
testcase_57 | AC | 41 ms
5,632 KB |
testcase_58 | AC | 12 ms
5,248 KB |
testcase_59 | AC | 2 ms
5,248 KB |
testcase_60 | AC | 39 ms
5,504 KB |
testcase_61 | AC | 2 ms
5,248 KB |
testcase_62 | AC | 19 ms
5,248 KB |
testcase_63 | AC | 58 ms
6,400 KB |
testcase_64 | AC | 38 ms
6,400 KB |
testcase_65 | AC | 2 ms
5,248 KB |
testcase_66 | AC | 14 ms
5,248 KB |
testcase_67 | AC | 20 ms
5,248 KB |
testcase_68 | AC | 20 ms
5,248 KB |
testcase_69 | AC | 2 ms
5,248 KB |
testcase_70 | AC | 23 ms
5,248 KB |
testcase_71 | AC | 58 ms
6,528 KB |
testcase_72 | AC | 58 ms
6,400 KB |
testcase_73 | AC | 57 ms
6,656 KB |
testcase_74 | AC | 58 ms
6,656 KB |
testcase_75 | AC | 58 ms
6,400 KB |
testcase_76 | AC | 58 ms
6,656 KB |
testcase_77 | AC | 58 ms
6,400 KB |
testcase_78 | AC | 2 ms
5,248 KB |
testcase_79 | AC | 2 ms
5,248 KB |
testcase_80 | AC | 57 ms
6,400 KB |
testcase_81 | AC | 58 ms
6,656 KB |
testcase_82 | AC | 57 ms
6,528 KB |
testcase_83 | AC | 37 ms
6,400 KB |
testcase_84 | AC | 10 ms
5,248 KB |
testcase_85 | AC | 38 ms
5,760 KB |
testcase_86 | AC | 24 ms
5,248 KB |
testcase_87 | AC | 21 ms
5,248 KB |
testcase_88 | AC | 3 ms
5,248 KB |
testcase_89 | AC | 3 ms
5,248 KB |
testcase_90 | AC | 47 ms
6,272 KB |
testcase_91 | AC | 5 ms
5,248 KB |
testcase_92 | AC | 4 ms
5,248 KB |
testcase_93 | AC | 24 ms
5,760 KB |
testcase_94 | AC | 15 ms
5,248 KB |
testcase_95 | AC | 11 ms
5,248 KB |
testcase_96 | AC | 9 ms
5,248 KB |
testcase_97 | AC | 3 ms
5,248 KB |
testcase_98 | AC | 29 ms
6,400 KB |
ソースコード
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define LL long long #define DB double #define LD long double #define ST string #define BS bitset #define PA pair<LL,LL> #define VE vector #define VL VE<LL> #define VP VE<PA> #define VVL VE<VL> #define VVVL VE<VVL> #define PQ priority_queue #define PQS priority_queue<LL,vector<LL>,greater<LL>> #define FI first #define SE second #define PB push_back #define POB pop_back #define PF push_front #define POF pop_front #define MP make_pair #define TS to_string #define TU to_ullong #define BPL __builtin_popcountll #define FOR(i,a,n) for(i=a;i<n;++i) #define FORR(i,a,n) for(i=n-1;i>=a;--i) #define rep(i,n) FOR(i,0,n) #define repr(i,n) FORR(i,0,n) #define ALL(a) a.begin(),a.end() #define RALL(a) a.rbegin(),a.rend() #define SORT(a) sort(ALL(a)) #define REV(a) reverse(ALL(a)) #define UB(a,n) *upper_bound(ALL(a),n) #define UBn(a,n) upper_bound(ALL(a),n)-a.begin() #define LB(a,n) *lower_bound(ALL(a),n) #define LBn(a,n) lower_bound(ALL(a),n)-a.begin() #define INF 1000000000000000003 #define PI 3.14159265358979323846264338327950288 //#define MOD 1000000007 #define MOD 998244353 #define ERR 1e-10 #define coutl cout<<fixed<<setprecision(15) #define FAST cin.tie(0);ios::sync_with_stdio(false) void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");} void YN(LL a){if(a)printf("YES\n");else printf("NO\n");} void vout(VL &v){LL i;rep(i,v.size()){printf("%lld",v[i]);if(i<v.size()-1)printf(" ");}printf("\n");} void v2out(VVL &v){LL i;rep(i,v.size())vout(v[i]);} LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;} LL dig(LL n){LL ret=0;while(n)n/=10,++ret;return ret;} LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;} LL LCM(LL a,LL b){return a*b/GCD(a,b);} LL cmod(LL a,LL m){if(a%m<0)return a%m+abs(m);else return a%m;} LL DIV(LL a,LL d,LL m){LL l=m,x=1,y=0,k;while(l){k=d/l;d-=k*l;swap(l,d);x-=k*y;swap(x,y);}return cmod(a*cmod(x,m),m);} LL POW(LL a,LL n,LL m){LL ans=1;while(n>0){if(n&1)ans=ans*a%m;a=a*a%m;n>>=1;}return ans;} VL fact,finv,inv; void comi(LL n){LL i;fact.resize(max(2LL,n+1));finv.resize(max(2LL,n+1));inv.resize(max(2LL,n+1));fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,n+1){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}} LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;} bool cmps(PA a,PA b){if(a.SE!=b.SE)return a.SE<b.SE;return a.FI<b.FI;} template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;} template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;} int main(){ FAST; LL i,j,N,X,Y,a,b,f=0; cin>>N>>X>>Y; VL A(N),ans(N); rep(i,N)cin>>A[i]; a=Y,b=~Y; repr(i,N){ //cout<<a<<" "<<b<<endl; if(((a&A[i])==a)&&((b&A[i])==0)){ ans[i]=3; break; } else if((A[i]&b)==0){ ans[i]=2; a&=(~A[i]); } else if((A[i]&a)==a){ ans[i]=1; b&=A[i]; } else{ f=1; break; } } if(f){ cout<<-1<<endl; return 0; } rep(i,N)if(!ans[i])ans[i]=3; //vout(ans); rep(i,N){ if(ans[i]==1)X&=A[i]; if(ans[i]==2)X|=A[i]; if(ans[i]==3)X=A[i]; } if(X!=Y){ cout<<-1<<endl; return 0; } vout(ans); }