답안 #148361

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148361 2019-09-01T04:05:42 Z Ian and 2-bit memory(#3648, percywtc, nhho, ulna) List of Unique Integers (FXCUP4_unique) C++17
컴파일 오류
0 ms 0 KB
#include "unique.h"

std::vector<int> PickUnique(int N) {
	vector<int> ans = vector<int>(N, 1);

	int prv = 0;
	for (int i = 0; i < N; i++) {
		int ver = UniqueCount(0, i);
		if (ver != prv) {
			ans[i] = 0;
		}
		prv = ver;
	}

	prv = 0;
	for (int i = N - 1; i >= 0; i--) {
		int ver = UniqueCount(0, i);
		if (ver != prv) {
			ans[i] = 0;
		}
		prv = ver;
	}

	return ans;
}

Compilation message

unique.cpp: In function 'std::vector<int> PickUnique(int)':
unique.cpp:4:2: error: 'vector' was not declared in this scope
  vector<int> ans = vector<int>(N, 1);
  ^~~~~~
unique.cpp:4:2: note: suggested alternative:
In file included from /usr/include/c++/7/vector:64:0,
                 from unique.h:1,
                 from unique.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:216:11: note:   'std::vector'
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
unique.cpp:4:9: error: expected primary-expression before 'int'
  vector<int> ans = vector<int>(N, 1);
         ^~~
unique.cpp:10:4: error: 'ans' was not declared in this scope
    ans[i] = 0;
    ^~~
unique.cpp:19:4: error: 'ans' was not declared in this scope
    ans[i] = 0;
    ^~~
unique.cpp:24:9: error: 'ans' was not declared in this scope
  return ans;
         ^~~