Submission #149878

#TimeUsernameProblemLanguageResultExecution timeMemory
149878GojekKawe (#200)List of Unique Integers (FXCUP4_unique)C++17
100 / 100
6 ms512 KiB
#include "unique.h" std::vector<int> PickUnique (int N){ int U[N]; int left[N]; int right[N]; for(int i=0;i<N;i++){ left[i]=0; } for(int i=0;i<N;i++){ right[i]=0; } int k=UniqueCount(0,N-1); for(int i=1;i<N-1;i++){ left[i]=UniqueCount(0,i); } for(int i=1;i<N-1;i++){ right[i]=UniqueCount(i,N-1); } right[N-1]=1; right[0]=k; left[0]=1; left[N-1]=k; for(int i=0;i<N;i++){ U[i]=0; } if(k==left[N-2]+1){ U[N-1]=1; }; if(k==right[1]+1){ U[0]=1; }; for(int i=N-2; i>0;i--){ if(right[i]==right[i+1]+1){ if(left[i]==left[i-1]+1) U[i]=1; } }; std::vector<int> vect(U, U + sizeof(U)/sizeof(U[0])); return vect; }
#Verdict Execution timeMemoryGrader output
Fetching results...