結果

問題 No.1017 Reiwa Sequence
ユーザー chocopuuchocopuu
提出日時 2020-04-19 16:57:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 575 ms / 2,000 ms
コード長 1,369 bytes
コンパイル時間 2,309 ms
コンパイル使用メモリ 210,720 KB
実行使用メモリ 37,880 KB
最終ジャッジ日時 2023-09-16 07:21:46
合計ジャッジ時間 21,710 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 8 ms
4,424 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 454 ms
36,432 KB
testcase_20 AC 498 ms
36,124 KB
testcase_21 AC 520 ms
36,128 KB
testcase_22 AC 483 ms
36,184 KB
testcase_23 AC 411 ms
36,192 KB
testcase_24 AC 391 ms
36,188 KB
testcase_25 AC 361 ms
36,120 KB
testcase_26 AC 320 ms
36,320 KB
testcase_27 AC 281 ms
24,484 KB
testcase_28 AC 360 ms
27,956 KB
testcase_29 AC 7 ms
4,384 KB
testcase_30 AC 12 ms
4,952 KB
testcase_31 AC 34 ms
7,544 KB
testcase_32 AC 161 ms
19,764 KB
testcase_33 AC 5 ms
4,384 KB
testcase_34 AC 151 ms
19,920 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 182 ms
19,804 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 191 ms
19,744 KB
testcase_40 AC 575 ms
37,552 KB
testcase_41 AC 507 ms
37,880 KB
testcase_42 AC 526 ms
37,624 KB
testcase_43 AC 512 ms
37,696 KB
testcase_44 AC 34 ms
4,868 KB
testcase_45 AC 504 ms
37,516 KB
testcase_46 AC 424 ms
37,512 KB
testcase_47 AC 336 ms
37,692 KB
testcase_48 AC 55 ms
6,376 KB
testcase_49 AC 53 ms
6,236 KB
testcase_50 AC 56 ms
6,304 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 367 ms
35,928 KB
testcase_53 AC 73 ms
11,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e9;

signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	REP(i,N){
		cin >> a[i];
	}
	int n = N;
	CHMIN(N,22ll);
	map<int,int>mp;
	REP(i,1ll << N){
		int sum = 0;
		REP(j,N){
			if((1ll << j) & i){
				sum += a[j];
			}
		}
		if(mp.count(sum)){
			int I = mp[sum];
			int J = i;
			int kaburi = I & J;
			I ^= kaburi;
			J ^= kaburi;
			vector<int>ans;
			REP(j,N){
				if((1ll << j) & I)ans.emplace_back(a[j]);
				else if((1ll << j) & J)ans.emplace_back(-a[j]);
				else ans.emplace_back(0);
			}
			FOR(j,N,n)ans.emplace_back(0);
			out("Yes");
			REP(i,ans.size())cout << ans[i] << " \n"[i+1 == ans.size()];
			return 0;
		}else mp[sum] = i;
	}
	out("No");
}
0