Submission #149534

#TimeUsernameProblemLanguageResultExecution timeMemory
149534티셔츠 콜렉터 (#200)List of Unique Integers (FXCUP4_unique)C++17
Compilation error
0 ms0 KiB
#include "unique.h" std::vector<int> PickUnique(int N) { int result[N]; int leftIndex = 0; int rightIndex = N-1; while (leftIndex < rightIndex) { int totalUniqueCount = UniqueCount(leftIndex, rightIndex); int leftUniqueCount = UniqueCount(leftIndex + 1, rightIndex); int rightUniqueCount = UniqueCount(leftIndex, rightIndex - 1); if (totalUniqueCount <= leftUniqueCount) { result.push_back[leftIndex] = 0; } else if (totalUniqueCount <= rightUniqueCount) { result[rightIndex] = 0; } else { if (totalUniqueCount > leftUniqueCount) { result[leftIndex] = 1; } if (totalUniqueCount > rightUniqueCount) { result[rightIndex] = 1; } } leftIndex++; rightIndex--; } std::vector<int> output; for (int i = 0; i < sizeof(result); i++) { output.push_back(result[i]); } return output; }

Compilation message (stderr)

unique.cpp: In function 'std::vector<int> PickUnique(int)':
unique.cpp:13:20: error: request for member 'push_back' in 'result', which is of non-class type 'int [N]'
             result.push_back[leftIndex] = 0;
                    ^~~~~~~~~
unique.cpp:29:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < sizeof(result); i++) {
                     ~~^~~~~~~~~