結果

問題 No.1355 AND OR GAME
ユーザー tarakojo1019tarakojo1019
提出日時 2021-01-18 11:09:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 1,467 bytes
コンパイル時間 3,639 ms
コンパイル使用メモリ 116,044 KB
実行使用メモリ 6,796 KB
最終ジャッジ日時 2023-08-20 18:43:57
合計ジャッジ時間 13,157 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,504 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 13 ms
4,380 KB
testcase_35 AC 124 ms
6,776 KB
testcase_36 AC 114 ms
6,488 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 126 ms
6,772 KB
testcase_39 AC 44 ms
4,376 KB
testcase_40 AC 60 ms
4,736 KB
testcase_41 AC 123 ms
6,768 KB
testcase_42 AC 122 ms
6,608 KB
testcase_43 AC 72 ms
4,380 KB
testcase_44 AC 19 ms
4,376 KB
testcase_45 AC 124 ms
6,788 KB
testcase_46 AC 46 ms
4,752 KB
testcase_47 AC 123 ms
6,604 KB
testcase_48 AC 88 ms
6,208 KB
testcase_49 AC 125 ms
6,776 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 62 ms
4,820 KB
testcase_52 AC 110 ms
6,636 KB
testcase_53 AC 76 ms
4,988 KB
testcase_54 AC 122 ms
6,660 KB
testcase_55 AC 107 ms
4,604 KB
testcase_56 AC 109 ms
4,592 KB
testcase_57 AC 86 ms
6,292 KB
testcase_58 AC 25 ms
4,380 KB
testcase_59 AC 2 ms
4,380 KB
testcase_60 AC 82 ms
6,076 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 58 ms
4,380 KB
testcase_63 AC 124 ms
6,592 KB
testcase_64 AC 109 ms
4,656 KB
testcase_65 AC 2 ms
4,376 KB
testcase_66 AC 37 ms
4,380 KB
testcase_67 AC 39 ms
4,380 KB
testcase_68 AC 39 ms
4,380 KB
testcase_69 AC 1 ms
4,380 KB
testcase_70 AC 47 ms
4,768 KB
testcase_71 AC 123 ms
6,704 KB
testcase_72 AC 123 ms
6,656 KB
testcase_73 AC 124 ms
6,788 KB
testcase_74 AC 123 ms
6,704 KB
testcase_75 AC 124 ms
6,796 KB
testcase_76 AC 124 ms
6,648 KB
testcase_77 AC 123 ms
6,768 KB
testcase_78 AC 1 ms
4,376 KB
testcase_79 AC 1 ms
4,376 KB
testcase_80 AC 122 ms
6,604 KB
testcase_81 AC 123 ms
6,652 KB
testcase_82 AC 130 ms
6,648 KB
testcase_83 AC 121 ms
4,596 KB
testcase_84 AC 22 ms
4,384 KB
testcase_85 AC 63 ms
6,404 KB
testcase_86 AC 39 ms
4,784 KB
testcase_87 AC 34 ms
4,808 KB
testcase_88 AC 4 ms
4,376 KB
testcase_89 AC 3 ms
4,376 KB
testcase_90 AC 76 ms
6,516 KB
testcase_91 AC 9 ms
4,380 KB
testcase_92 AC 5 ms
4,376 KB
testcase_93 AC 54 ms
6,312 KB
testcase_94 AC 33 ms
4,796 KB
testcase_95 AC 24 ms
4,524 KB
testcase_96 AC 18 ms
4,376 KB
testcase_97 AC 4 ms
4,380 KB
testcase_98 AC 66 ms
6,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<numeric>
#include<cstring>
#include<random>
#include<array>
#include<fstream>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<queue>

/*
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

using namespace std;

using ll = long long;
using ull = unsigned long long;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) std::cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", (double)v)

template<typename A, typename B>void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>void maxs(A& a, const B& b) { a = max(a, (A)b); };



int main() {
	ll N, X, Y; cin >> N >> X >> Y;
	vector<ll> A(N+1);
	vector<ll> P;
	A[0] = X;
	REP(i, 1, N+1) cin >> A[i];
	reverse(A.begin(), A.end());
	ll a = Y;
	ll b = ~Y;
	REP(i, 0, N+1) {
		if ((~A[i] & a) == 0) {
			if ((b & A[i]) == 0) {
				if(P.size() < N) P.push_back(3);
				while (P.size() != N) P.push_back(1);
				reverse(P.begin(), P.end());
				for (ll p : P) cout << p << " ";
				cout << endl;
				return 0;
			}

			b = b & A[i];
			P.push_back(1);
		}
		else if ((b & A[i]) == 0) {
			a = a & ~A[i];
			P.push_back(2);
		}
		else {
			PRI(-1);
			return 0;
		}
	}
	PRI(-1);
	return 0;
}
0