Submission #298810

# Submission time Handle Problem Language Result Execution time Memory
298810 2020-09-14T06:06:18 Z eggag32 List of Unique Integers (FXCUP4_unique) C++17
100 / 100
1 ms 640 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include "unique.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

vi PickUnique(int n){
	vi l(n, 0), r(n, 0);
	rep(i, n) l[i] = UniqueCount(0, i);
	for(int i = n - 1; i >= 0; i--) r[i] = UniqueCount(i, n - 1);
	vi ans(n, 0);
	rep(i, n){
		if(!i) ans[i] = (r[i] > r[i + 1]);
		else if(i == (n - 1)) ans[i] = (l[i] > l[i - 1]);
		else ans[i] = ((l[i] > l[i - 1]) && (r[i] > r[i + 1]));
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Correct : C = 4
2 Correct 1 ms 384 KB Correct : C = 10
3 Correct 1 ms 384 KB Correct : C = 50
4 Correct 1 ms 512 KB Correct : C = 100
5 Correct 1 ms 384 KB Correct : C = 100
6 Correct 1 ms 384 KB Correct : C = 154
7 Correct 1 ms 384 KB Correct : C = 200
8 Correct 1 ms 512 KB Correct : C = 300
9 Correct 1 ms 512 KB Correct : C = 356
10 Correct 1 ms 512 KB Correct : C = 400
11 Correct 1 ms 512 KB Correct : C = 400
12 Correct 1 ms 640 KB Correct : C = 400
13 Correct 1 ms 512 KB Correct : C = 400
14 Correct 1 ms 512 KB Correct : C = 400
15 Correct 1 ms 512 KB Correct : C = 400