結果

問題 No.1017 Reiwa Sequence
ユーザー leaf_1415leaf_1415
提出日時 2020-04-04 04:29:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,340 bytes
コンパイル時間 1,617 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 36,296 KB
最終ジャッジ日時 2023-09-16 05:20:49
合計ジャッジ時間 18,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 2 ms
4,376 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 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 9 ms
4,472 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 520 ms
36,296 KB
testcase_20 AC 555 ms
36,156 KB
testcase_21 AC 575 ms
36,092 KB
testcase_22 AC 542 ms
36,096 KB
testcase_23 AC 440 ms
36,168 KB
testcase_24 AC 437 ms
36,136 KB
testcase_25 AC 400 ms
36,144 KB
testcase_26 AC 345 ms
36,184 KB
testcase_27 AC 311 ms
24,448 KB
testcase_28 AC 402 ms
28,048 KB
testcase_29 AC 7 ms
4,380 KB
testcase_30 AC 12 ms
4,992 KB
testcase_31 AC 37 ms
7,616 KB
testcase_32 AC 170 ms
19,800 KB
testcase_33 AC 5 ms
4,380 KB
testcase_34 AC 173 ms
19,924 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 201 ms
19,776 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 199 ms
19,800 KB
testcase_40 WA -
testcase_41 TLE -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
権限があれば一括ダウンロードができます

ソースコード

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