Submission #247088

#TimeUsernameProblemLanguageResultExecution timeMemory
247088shenxyList of Unique Integers (FXCUP4_unique)C++17
100 / 100
5 ms768 KiB
#include "unique.h"
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
vector<int> PickUnique(int N) {
	bool preun[N], postun[N];
	fill_n(preun, N, false);
	fill_n(postun, N, false);
	int pre = 0;
	for (int i = 0; i < N; ++i) {
		int k = UniqueCount(0, i);
		if (k > pre) preun[i] = true;
		pre = k;
	}
	pre = 0;
	for (int i = N - 1; i >= 0; --i) {
		int k = UniqueCount(i, N - 1);
		if (k > pre) postun[i] = true;
		pre = k;
	}
	vector<int> ans;
	for (int i = 0; i < N; ++i) {
		if (preun[i] && postun[i]) ans.push_back(1);
		else ans.push_back(0);
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...