結果

問題 No.1017 Reiwa Sequence
ユーザー 00 Sakuda00 Sakuda
提出日時 2024-04-01 02:16:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,102 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 207,924 KB
実行使用メモリ 22,196 KB
最終ジャッジ日時 2024-04-01 02:17:01
合計ジャッジ時間 37,714 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
19,680 KB
testcase_01 AC 7 ms
19,680 KB
testcase_02 AC 7 ms
19,680 KB
testcase_03 AC 7 ms
19,684 KB
testcase_04 AC 7 ms
19,680 KB
testcase_05 AC 7 ms
19,680 KB
testcase_06 AC 6 ms
19,680 KB
testcase_07 AC 7 ms
19,680 KB
testcase_08 AC 7 ms
19,680 KB
testcase_09 AC 7 ms
19,684 KB
testcase_10 AC 7 ms
19,684 KB
testcase_11 AC 7 ms
19,684 KB
testcase_12 AC 8 ms
19,684 KB
testcase_13 AC 7 ms
19,684 KB
testcase_14 AC 7 ms
19,684 KB
testcase_15 AC 7 ms
19,684 KB
testcase_16 AC 7 ms
19,684 KB
testcase_17 AC 8 ms
19,684 KB
testcase_18 AC 7 ms
19,684 KB
testcase_19 AC 37 ms
19,684 KB
testcase_20 AC 34 ms
19,684 KB
testcase_21 AC 35 ms
19,684 KB
testcase_22 AC 35 ms
19,684 KB
testcase_23 AC 32 ms
19,684 KB
testcase_24 AC 38 ms
19,684 KB
testcase_25 AC 29 ms
19,684 KB
testcase_26 AC 23 ms
19,684 KB
testcase_27 AC 25 ms
19,684 KB
testcase_28 AC 23 ms
19,684 KB
testcase_29 AC 8 ms
19,684 KB
testcase_30 AC 9 ms
19,684 KB
testcase_31 AC 11 ms
19,684 KB
testcase_32 AC 18 ms
19,684 KB
testcase_33 AC 7 ms
19,684 KB
testcase_34 AC 22 ms
19,684 KB
testcase_35 AC 7 ms
19,684 KB
testcase_36 AC 7 ms
19,684 KB
testcase_37 AC 22 ms
19,684 KB
testcase_38 AC 6 ms
19,684 KB
testcase_39 AC 23 ms
19,684 KB
testcase_40 AC 77 ms
21,372 KB
testcase_41 AC 74 ms
21,372 KB
testcase_42 AC 78 ms
21,276 KB
testcase_43 AC 74 ms
21,336 KB
testcase_44 AC 43 ms
21,372 KB
testcase_45 AC 66 ms
21,344 KB
testcase_46 AC 64 ms
21,288 KB
testcase_47 AC 56 ms
21,276 KB
testcase_48 AC 65 ms
22,196 KB
testcase_49 AC 67 ms
22,196 KB
testcase_50 AC 69 ms
22,196 KB
testcase_51 AC 6 ms
19,680 KB
testcase_52 AC 24 ms
19,684 KB
testcase_53 AC 11 ms
19,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace atcoder;
using namespace std;
using ll = long long;
ll INF = (1LL << 60);
bool ret = false;
vector<ll> solve(vector<ll> A) {
	int N = A.size();
	vector<int> IS((1 << 22) + 1, -1);
	vector<ll> ans = A;
	for (int bit = 0;bit < (1 << N);bit++) {
		ll s = 0;
		for (int i = 0;i < N;i++) s += (bit & (1 << i) ? 1 : 0) * A[i];
		if (IS[s] == -1) {
			IS[s] = bit;
			continue;
		}
		int type = IS[s];
		ret = true;
		for (int i = 0;i < N;i++) {
			bool t1 = bit & (1 << i);
			bool t2 = type & (1 << i);
			if (t1 and t2) {
				ans[i] = 0;
			} else if (t1) {
				
			} else if (t2) {
				ans[i] *= -1;
			} else {
				ans[i] = 0;
			}
		}
		break;
	}
	return ans;
}
int main() {
	int N;cin >> N;
	vector<ll> A(N);
	vector<ll> B, C;
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		if (i < 22) {
			B.push_back(A[i]);
		} else {
			C.push_back(0);
		}
	}
	vector<ll> D = solve(B);
	if (!ret) {
		cout << "No" << endl;return 0;
	}
	cout << "Yes" << endl;
	for (auto v : D) cout << v << " ";
	for (auto v : C) cout << v << " ";
	cout << endl;
}
0