結果

問題 No.332 数列をプレゼントに
ユーザー yumakmcyumakmc
提出日時 2016-02-23 20:10:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,675 bytes
コンパイル時間 3,051 ms
コンパイル使用メモリ 187,284 KB
実行使用メモリ 158,784 KB
最終ジャッジ日時 2023-10-23 19:29:47
合計ジャッジ時間 11,582 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 13 ms
7,324 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 23 ms
7,416 KB
testcase_16 AC 6 ms
4,940 KB
testcase_17 AC 6 ms
4,988 KB
testcase_18 AC 11 ms
6,172 KB
testcase_19 AC 8 ms
5,420 KB
testcase_20 AC 17 ms
6,884 KB
testcase_21 AC 30 ms
8,808 KB
testcase_22 AC 19 ms
7,032 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 8 ms
5,568 KB
testcase_34 AC 9 ms
5,808 KB
testcase_35 AC 11 ms
6,224 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 5 ms
4,580 KB
testcase_38 AC 4 ms
4,584 KB
testcase_39 AC 4 ms
4,580 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 3 ms
4,348 KB
testcase_43 AC 9 ms
4,856 KB
testcase_44 AC 5 ms
4,528 KB
testcase_45 AC 16 ms
9,792 KB
testcase_46 AC 14 ms
7,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

void cou(vector<int>bs) {
	for (int i = 0; i < bs.size(); ++i) {
		if (bs[i]) {
			cout << 'o';
		}
		else {
			cout << 'x';
		}
	}
	cout << endl;
}

vector<pair<long long int,int>>as;
int main() {
	long long int N, X; cin >> N >> X;
	as.resize(N);
	for (int i = 0; i < N; ++i) {
		cin >> as[i].first;
		as[i].second = i;
	}
	sort(as.begin(),as.end());
	unordered_map<long long int,vector<int>>premap;
	premap[0] = vector<int>(N);
	int now = 0;
	while (premap.size() < 100000&&now!=N) {
		unordered_map<long long int , vector<int>>newmap(premap);
		for (auto i : premap) {
			i.second[as[now].second]=(true);
			newmap[i.first+as[now].first] =i.second;
		}
		premap = newmap;
		now++;
	}
	if (now == N) {
		auto ansit = premap.find(X);
		if (ansit != premap.end()) {
			cou(ansit->second);
		}
		else {
			cout << "No" << endl;
		}
		return 0;
	}
	else {
		map<long long int, vector<int>>lastmap;
		lastmap[0]=vector<int>(N);
		while (now != N) {
			map<long long int, vector<int>>newmap(lastmap);	
			for (auto i : lastmap) {
				i.second[as[now].second] = (true);
				newmap[i.first + as[now].first] = i.second;
			}
			lastmap = newmap;
			now++;
		}
		for (const auto& p : premap) {
			auto ansit = lastmap.find(p.first);
			if (ansit != lastmap.end()) {
				vector<int>ansbs(p.second);
				for (int i = 0; i < N; ++i) {
					ansbs[i] = ansbs[i] || ansit->second[i];
				}
				cou(ansit->second);
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}
	return 0;
}
0