Submission #230542

#TimeUsernameProblemLanguageResultExecution timeMemory
230542jiahngList of Unique Integers (FXCUP4_unique)C++17
100 / 100
5 ms512 KiB
#include <bits/stdc++.h>
#include "unique.h"
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)



std::vector<int> PickUnique(int N) {
	vi ans;
	int pre = 0;
	int suff = UniqueCount(0,N-1);
	
	FOR(i,0,N-1){
		int yes = 0;
		int x = UniqueCount(0,i);
		if (i == 0 || pre + 1 == x) yes++;
		
		pre = x;
		
		int y;
		if (i + 1 == N) y = 0;
		else y = UniqueCount(i+1,N-1);
		
		if (i == N-1 || y + 1 == suff){
			yes++;
		}
		
		suff = y;
		
		if (yes == 2) ans.pb(1);
		else ans.pb(0);
	}
	//aFOR(i,ans) cout<<i<<' ';
	
	return ans;
}

#Verdict Execution timeMemoryGrader output
Fetching results...