結果

問題 No.332 数列をプレゼントに
ユーザー yumakmcyumakmc
提出日時 2016-02-23 19:46:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,719 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 188,220 KB
実行使用メモリ 814,624 KB
最終ジャッジ日時 2023-10-23 19:28:25
合計ジャッジ時間 8,929 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 TLE -
testcase_06 MLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

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<long long 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];
	}
	sort(as.begin(),as.end());
	unordered_map<long long int,vector<int>>premap;
	premap[0] = vector<int>();
	int now = 0;
	while (premap.size() < 500000&&now!=N) {
		unordered_map<long long int , vector<int>>newmap(premap);
		for (auto& i : newmap) {
			i.second.emplace_back(false);
		}
		for (auto i : premap) {
			i.second.emplace_back(true);
			newmap[i.first+as[now]] =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];
		while (now != N) {
			map<long long int, vector<int>>newmap(lastmap);
			for (auto& i : newmap) {
				i.second.emplace_back(false);
			}
			for (auto i : premap) {
				i.second.emplace_back(true);
				newmap[i.first + as[now]] = 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);
				ansbs.insert(ansbs.end(), ansit->second.begin(), ansit->second.end());
				cou(ansit->second);
				return 0;
			}
		}
		cout << "No" << endl;
		return 0;
	}
	return 0;
}
0