답안 #148913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148913 2019-09-01T05:22:12 Z 샌즈뼈(#3582, exqt, esselem) List of Unique Integers (FXCUP4_unique) C++17
0 / 100
6 ms 384 KB
#include "unique.h"
using namespace std;
std::vector<int> PickUnique(int N)
{
    vector<int> ans(N,0);

    int i,j,v1,v2;
    int base = UniqueCount(0,N-1);
    int f[211]={};

    v1=base;
    for (i=1;i<N-1;i++)
    {
        v2=UniqueCount(i,N-1);
        if (v1>v2) f[i-1]++;
        v1=v2;
    }

    v1=base;
    for (i=N-2;i>=1;i--)
    {
        v2=UniqueCount(0,i);
        if (v1>v2) f[i+1]++;
        v1=v2;
    }

    for (i=1;i<N-1;i++) if (f[i]==2) ans[i]=1;
    if (f[0]==1) ans[0]=1;
    if (f[N-1]==1) ans[N-1]=1;

	return ans;
}

Compilation message

unique.cpp: In function 'std::vector<int> PickUnique(int)':
unique.cpp:7:11: warning: unused variable 'j' [-Wunused-variable]
     int i,j,v1,v2;
           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Correct : C = 1
2 Correct 5 ms 256 KB Correct : C = 7
3 Correct 6 ms 256 KB Correct : C = 47
4 Incorrect 5 ms 384 KB Wrong
5 Halted 0 ms 0 KB -