답안 #149586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149586 2019-09-01T06:47:23 Z 티셔츠 콜렉터(#3632, yoni, jisunchae, jsg1504) List of Unique Integers (FXCUP4_unique) C++17
컴파일 오류
0 ms 0 KB
#include "unique.h"

int min (int x, int y) {
    return x < y ? x : y;
}

std::vector<int> PickUnique(int N) {
    int result[N];
    int leftIndex = 0;
    int rightIndex = N-1;
    while (leftIndex < rightIndex) {
        int totalUniqueCount = UniqueCount(0, N-1);
        int prevCount = UniqueCount(leftIndex, rightIndex);
        int minCount = min(totalUniqueCount, prevCount)
        int leftUniqueCount = UniqueCount(leftIndex + 1, rightIndex);
        int rightUniqueCount = UniqueCount(leftIndex, rightIndex - 1);
        
        if (minCount <= leftUniqueCount && ) {
            result[leftIndex] = 0;
        } else if (minCount <= rightUniqueCount) {
            result[rightIndex] = 0;
        } else {
            if (minCount > leftUniqueCount) {
                result[leftIndex] = 1;
            }
            if (minCount > rightUniqueCount) {
                result[rightIndex] = 1;
            }
        }
        leftIndex++;
        rightIndex--;
    }

    std::vector<int> output;
    for (int i = 0; i < N; i++) {
        output.push_back(result[i]);
    }
	return output;
}

Compilation message

unique.cpp: In function 'std::vector<int> PickUnique(int)':
unique.cpp:15:9: error: expected ',' or ';' before 'int'
         int leftUniqueCount = UniqueCount(leftIndex + 1, rightIndex);
         ^~~
unique.cpp:18:25: error: 'leftUniqueCount' was not declared in this scope
         if (minCount <= leftUniqueCount && ) {
                         ^~~~~~~~~~~~~~~
unique.cpp:18:25: note: suggested alternative: 'rightUniqueCount'
         if (minCount <= leftUniqueCount && ) {
                         ^~~~~~~~~~~~~~~
                         rightUniqueCount
unique.cpp:18:44: error: expected primary-expression before ')' token
         if (minCount <= leftUniqueCount && ) {
                                            ^