結果

問題 No.1355 AND OR GAME
ユーザー 👑 kmjpkmjp
提出日時 2021-01-17 15:37:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,772 bytes
コンパイル時間 2,458 ms
コンパイル使用メモリ 213,488 KB
実行使用メモリ 814,392 KB
最終ジャッジ日時 2024-05-07 04:59:00
合計ジャッジ時間 11,513 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
12,776 KB
testcase_01 AC 6 ms
13,048 KB
testcase_02 AC 6 ms
13,720 KB
testcase_03 AC 6 ms
13,768 KB
testcase_04 AC 5 ms
13,932 KB
testcase_05 AC 5 ms
13,632 KB
testcase_06 AC 6 ms
13,036 KB
testcase_07 AC 5 ms
13,636 KB
testcase_08 AC 6 ms
13,636 KB
testcase_09 AC 5 ms
13,768 KB
testcase_10 AC 5 ms
12,972 KB
testcase_11 AC 5 ms
13,640 KB
testcase_12 AC 5 ms
13,828 KB
testcase_13 AC 5 ms
13,764 KB
testcase_14 AC 5 ms
12,872 KB
testcase_15 AC 5 ms
13,636 KB
testcase_16 AC 5 ms
12,896 KB
testcase_17 AC 5 ms
13,632 KB
testcase_18 AC 5 ms
13,636 KB
testcase_19 AC 5 ms
13,148 KB
testcase_20 AC 6 ms
12,876 KB
testcase_21 AC 5 ms
13,752 KB
testcase_22 AC 5 ms
12,676 KB
testcase_23 AC 5 ms
12,956 KB
testcase_24 AC 5 ms
13,768 KB
testcase_25 AC 5 ms
14,012 KB
testcase_26 AC 5 ms
14,016 KB
testcase_27 AC 5 ms
13,636 KB
testcase_28 AC 5 ms
13,764 KB
testcase_29 AC 6 ms
13,944 KB
testcase_30 AC 6 ms
13,640 KB
testcase_31 AC 6 ms
12,828 KB
testcase_32 AC 5 ms
13,820 KB
testcase_33 AC 5 ms
13,760 KB
testcase_34 AC 11 ms
13,088 KB
testcase_35 AC 53 ms
15,296 KB
testcase_36 AC 49 ms
15,044 KB
testcase_37 AC 5 ms
14,172 KB
testcase_38 AC 53 ms
15,208 KB
testcase_39 MLE -
testcase_40 AC 30 ms
14,216 KB
testcase_41 AC 58 ms
15,156 KB
testcase_42 AC 56 ms
15,176 KB
testcase_43 MLE -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
testcase_94 -- -
testcase_95 -- -
testcase_96 -- -
testcase_97 -- -
testcase_98 -- -
権限があれば一括ダウンロードができます

ソースコード

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) {
					assert(M[i].count({o,a}));
					auto m2=M[i][{o,a}];
					o=m2.first.first;
					a=m2.first.second;
					ret[i]=m2.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};
		}
	}
	FORR(m,M[0]) {
		ll o=m.first.first;
		ll a=m.first.second;
		if(((X|o)&a)==Y) {
			i=0;
			while(i<N) {
				auto m2=M[i][{o,a}];
				o=m2.first.first;
				a=m2.first.second;
				ret[i]=m2.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