Submission #1101880

# Submission time Handle Problem Language Result Execution time Memory
1101880 2024-10-17T06:02:27 Z 0pt1mus23 List of Unique Integers (FXCUP4_unique) C++17
100 / 100
1 ms 612 KB
#include "unique.h"
#include <bits/stdc++.h>
using namespace std;
#define ins insert      
#define pb push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define _ << " " <<
mt19937 rng(time(0));

const int mod = 1e9 +9,
        sze = 5e3 +23,
        inf = INT_MAX,
        LL = 20;


std::vector<int> PickUnique(int n) {
	vector<int> ans(n,0);
	
	vector<int> pr(n+10,0);
	vector<int> sf(n+10,0);
	sf[0]=UniqueCount(0,n-1);
	for(int i=0;i<n;i++){
		int a=0;
		int b=0;
		int c=0;
		int d=0;
		if(i){
			a = pr[i-1];
		}
		b = UniqueCount(0,i);
		if(i+1<n){
			d = UniqueCount(i+1,n-1);
		}
		c = sf[i];
		if(a<b && c>d){
			ans[i]=1;
		}
		pr[i]=b;
		sf[i+1]=d;
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Correct : C = 4
2 Correct 1 ms 336 KB Correct : C = 10
3 Correct 1 ms 340 KB Correct : C = 50
4 Correct 1 ms 340 KB Correct : C = 100
5 Correct 1 ms 340 KB Correct : C = 100
6 Correct 1 ms 500 KB Correct : C = 154
7 Correct 1 ms 340 KB Correct : C = 200
8 Correct 1 ms 340 KB Correct : C = 300
9 Correct 1 ms 596 KB Correct : C = 356
10 Correct 1 ms 596 KB Correct : C = 400
11 Correct 1 ms 596 KB Correct : C = 400
12 Correct 1 ms 596 KB Correct : C = 400
13 Correct 1 ms 596 KB Correct : C = 400
14 Correct 1 ms 596 KB Correct : C = 400
15 Correct 1 ms 612 KB Correct : C = 400