답안 #148945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148945 2019-09-01T05:26:11 Z 샌즈뼈(#3582, exqt, esselem) List of Unique Integers (FXCUP4_unique) C++17
100 / 100
6 ms 512 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;
    }
    if (v1==2) f[N-2]++;

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

    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 5 ms 256 KB Correct : C = 1
2 Correct 5 ms 256 KB Correct : C = 7
3 Correct 6 ms 384 KB Correct : C = 47
4 Correct 5 ms 384 KB Correct : C = 97
5 Correct 5 ms 256 KB Correct : C = 97
6 Correct 5 ms 384 KB Correct : C = 151
7 Correct 5 ms 384 KB Correct : C = 197
8 Correct 5 ms 384 KB Correct : C = 297
9 Correct 5 ms 384 KB Correct : C = 353
10 Correct 5 ms 512 KB Correct : C = 397
11 Correct 5 ms 384 KB Correct : C = 397
12 Correct 5 ms 512 KB Correct : C = 397
13 Correct 5 ms 512 KB Correct : C = 397
14 Correct 5 ms 512 KB Correct : C = 397
15 Correct 6 ms 512 KB Correct : C = 397