結果

問題 No.1355 AND OR GAME
ユーザー 👑 kmjpkmjp
提出日時 2021-01-17 15:20:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,735 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 212,264 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-05-07 04:32:25
合計ジャッジ時間 33,370 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,928 KB
testcase_01 AC 6 ms
12,836 KB
testcase_02 AC 6 ms
13,056 KB
testcase_03 AC 6 ms
13,056 KB
testcase_04 AC 6 ms
13,056 KB
testcase_05 AC 5 ms
12,928 KB
testcase_06 AC 5 ms
12,800 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 7 ms
12,800 KB
testcase_10 AC 5 ms
12,928 KB
testcase_11 AC 5 ms
12,800 KB
testcase_12 WA -
testcase_13 AC 6 ms
12,928 KB
testcase_14 AC 5 ms
12,800 KB
testcase_15 AC 5 ms
12,928 KB
testcase_16 WA -
testcase_17 AC 5 ms
12,800 KB
testcase_18 WA -
testcase_19 AC 5 ms
12,928 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 6 ms
12,928 KB
testcase_23 AC 5 ms
12,928 KB
testcase_24 AC 5 ms
12,800 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 5 ms
12,928 KB
testcase_28 WA -
testcase_29 AC 5 ms
12,928 KB
testcase_30 AC 5 ms
12,928 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 5 ms
12,800 KB
testcase_34 WA -
testcase_35 AC 53 ms
15,292 KB
testcase_36 AC 49 ms
15,044 KB
testcase_37 AC 6 ms
12,800 KB
testcase_38 WA -
testcase_39 AC 723 ms
13,952 KB
testcase_40 AC 29 ms
14,080 KB
testcase_41 WA -
testcase_42 AC 53 ms
15,140 KB
testcase_43 AC 1,162 ms
14,464 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 23 ms
13,696 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 54 ms
15,232 KB
testcase_50 AC 6 ms
12,800 KB
testcase_51 AC 30 ms
14,272 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 51 ms
15,172 KB
testcase_55 AC 1,774 ms
15,156 KB
testcase_56 AC 1,794 ms
15,172 KB
testcase_57 AC 39 ms
14,592 KB
testcase_58 AC 15 ms
13,228 KB
testcase_59 AC 5 ms
12,800 KB
testcase_60 WA -
testcase_61 AC 5 ms
12,800 KB
testcase_62 AC 863 ms
14,080 KB
testcase_63 WA -
testcase_64 AC 1,791 ms
15,172 KB
testcase_65 WA -
testcase_66 AC 610 ms
13,824 KB
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 5 ms
12,928 KB
testcase_70 WA -
testcase_71 WA -
testcase_72 AC 54 ms
15,208 KB
testcase_73 AC 54 ms
15,216 KB
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 56 ms
15,248 KB
testcase_77 WA -
testcase_78 AC 5 ms
12,800 KB
testcase_79 AC 5 ms
12,928 KB
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 1,756 ms
15,232 KB
testcase_84 AC 24 ms
13,568 KB
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 AC 8 ms
12,928 KB
testcase_89 WA -
testcase_90 WA -
testcase_91 AC 13 ms
13,184 KB
testcase_92 WA -
testcase_93 AC 55 ms
14,708 KB
testcase_94 AC 35 ms
14,080 KB
testcase_95 AC 27 ms
13,824 KB
testcase_96 AC 22 ms
13,568 KB
testcase_97 AC 7 ms
13,056 KB
testcase_98 AC 68 ms
15,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
ll X,Y;
ll A[202020];
map<pair<ll,ll>,pair<pair<ll,ll>,int>> M[202020];
int ret[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>N>>X>>Y;
	FOR(i,N) cin>>A[i];
	M[N][{0,(1LL<<60)-1}]={{0,0},1};
	FOR(i,N) ret[i]=3;
	for(i=N-1;i>=0;i--) {
		FORR(m,M[i+1]) {
			ll o=m.first.first;
			ll a=m.first.second;
			if(((A[i]|o)&a)==Y) {
				i=i+1;
				while(i<N) {
					o=m.second.first.first;
					a=m.second.first.second;
					ret[i]=m.second.second;
					i++;
				}
				FOR(i,N) cout<<ret[i]<<" ";
				return;
			}
			//and
			ll am=(A[i]|o)&a;
			M[i][{o,am}]={{o,a},1};
			//or
			ll om=(A[i]&a)|o;
			M[i][{om,a}]={{o,a},2};
		}
		M[i+1].clear();
	}
	FORR(m,M[0]) {
		ll o=m.first.first;
		ll a=m.first.second;
		if(((X|o)&a)==Y) {
			while(i<N) {
				o=m.second.first.first;
				a=m.second.first.second;
				ret[i]=m.second.second;
				i++;
			}
			FOR(i,N) cout<<ret[i]<<" ";
			return;
		}
	}
	cout<<-1<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0