Submission #148424

#TimeUsernameProblemLanguageResultExecution timeMemory
148424ProofByTLE (#200)List of Unique Integers (FXCUP4_unique)C++17
0 / 100
5 ms256 KiB
#include "unique.h" std::vector<int> PickUnique(int N) { std::vector<int> answer(N, 0); // Iterate: prefix[i]: [0~i], suffix[i]: [i~end) std::vector<int> prefixUniqueCount(N, 0), suffixUniqueCount(N, 0); for(int left=0; left<N-1; left++){ suffixUniqueCount[left] = UniqueCount(left, N-1); prefixUniqueCount[left+1] = UniqueCount(0, left+1); } prefixUniqueCount[0] = 1; suffixUniqueCount.back() = 1; for(int mid=0; mid<N; mid++){ bool left = false, right = false; // Left if(mid == 0) left = true; else if(prefixUniqueCount[mid-1] == prefixUniqueCount[mid] - 1) left = true; // Right if(mid == N-1) right = true; else if(suffixUniqueCount[right+1] == suffixUniqueCount[right] - 1) right = true; answer[mid] = (int)(left && right); } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...