結果

問題 No.1017 Reiwa Sequence
ユーザー leaf_1415
提出日時 2020-04-04 04:29:21
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,340 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 38,236 KB
最終ジャッジ日時 2024-07-03 06:53:43
合計ジャッジ時間 31,886 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 36 WA * 1 TLE * 1 -- * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[150005];
P sum[300005];
map<llint, llint> mp;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	if(n == 1){
		cout << "No" << endl;
		return 0;
	}
	
	
	llint m = min(n, 23LL), M = 1 << m;
	for(int i = 1; i < M; i++){
		llint sum = 0;
		for(int j = 0; j < n; j++){
			if(i & (1<<j)) sum += a[j];
		}
		if(mp.count(sum)){
			llint x = i, y = mp[sum], z = x&y;
			x &= ~z, y &= ~z;
			cout << "Yes" << endl;
			for(int j = 0; j < n; j++){
				if(j < m && (x & (1<<j))) cout << a[j] << " ";
				else if(j < m && (y & (1<<j))) cout << -a[j] << " ";
				else cout << 0 << " ";
			}
			cout << endl;
			return 0;
		}
		mp[sum] = i;
	}
	cout << "No" << endl;
	
	return 0;
}
0