結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,928 KB
testcase_01 AC 5 ms
12,928 KB
testcase_02 AC 6 ms
12,928 KB
testcase_03 AC 6 ms
13,056 KB
testcase_04 AC 6 ms
13,056 KB
testcase_05 AC 6 ms
13,036 KB
testcase_06 AC 6 ms
12,808 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 9 ms
12,928 KB
testcase_10 AC 6 ms
12,800 KB
testcase_11 AC 6 ms
12,928 KB
testcase_12 WA -
testcase_13 AC 6 ms
12,820 KB
testcase_14 AC 6 ms
12,928 KB
testcase_15 AC 5 ms
12,928 KB
testcase_16 WA -
testcase_17 AC 6 ms
12,800 KB
testcase_18 WA -
testcase_19 AC 6 ms
12,800 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 6 ms
12,800 KB
testcase_23 AC 6 ms
12,928 KB
testcase_24 AC 7 ms
12,800 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 6 ms
12,800 KB
testcase_28 WA -
testcase_29 AC 6 ms
12,928 KB
testcase_30 AC 6 ms
12,800 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 6 ms
13,056 KB
testcase_34 WA -
testcase_35 AC 53 ms
15,168 KB
testcase_36 AC 49 ms
15,096 KB
testcase_37 AC 6 ms
12,928 KB
testcase_38 WA -
testcase_39 AC 690 ms
13,824 KB
testcase_40 AC 29 ms
13,952 KB
testcase_41 WA -
testcase_42 AC 54 ms
15,188 KB
testcase_43 AC 1,114 ms
14,464 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 24 ms
13,696 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 52 ms
15,300 KB
testcase_50 AC 6 ms
12,928 KB
testcase_51 AC 32 ms
14,080 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 52 ms
15,300 KB
testcase_55 AC 1,684 ms
15,232 KB
testcase_56 AC 1,705 ms
15,360 KB
testcase_57 AC 39 ms
14,440 KB
testcase_58 AC 17 ms
13,364 KB
testcase_59 AC 5 ms
12,800 KB
testcase_60 WA -
testcase_61 AC 7 ms
12,928 KB
testcase_62 AC 828 ms
13,952 KB
testcase_63 WA -
testcase_64 AC 1,709 ms
15,168 KB
testcase_65 WA -
testcase_66 AC 566 ms
13,824 KB
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 7 ms
12,800 KB
testcase_70 WA -
testcase_71 WA -
testcase_72 AC 51 ms
15,336 KB
testcase_73 AC 52 ms
15,176 KB
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 51 ms
15,176 KB
testcase_77 WA -
testcase_78 AC 7 ms
12,800 KB
testcase_79 AC 7 ms
12,800 KB
testcase_80 WA -
testcase_81 WA -
testcase_82 WA -
testcase_83 AC 1,679 ms
15,232 KB
testcase_84 AC 25 ms
13,696 KB
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 AC 10 ms
12,928 KB
testcase_89 WA -
testcase_90 WA -
testcase_91 AC 13 ms
13,184 KB
testcase_92 WA -
testcase_93 AC 56 ms
14,720 KB
testcase_94 AC 36 ms
14,080 KB
testcase_95 AC 27 ms
13,824 KB
testcase_96 AC 22 ms
13,568 KB
testcase_97 AC 9 ms
13,056 KB
testcase_98 AC 62 ms
15,352 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&A[i])|o;
			M[i][{o,am}]={{o,a},1};
			//or
			ll om=(o|A[i])&a;
			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