結果
| 問題 | 
                            No.332 数列をプレゼントに
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-02-23 20:10:54 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,675 bytes | 
| コンパイル時間 | 1,942 ms | 
| コンパイル使用メモリ | 187,128 KB | 
| 実行使用メモリ | 158,888 KB | 
| 最終ジャッジ日時 | 2024-09-22 13:13:17 | 
| 合計ジャッジ時間 | 12,026 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 23 WA * 19 | 
ソースコード
#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;
}