답안 #315045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315045 2020-10-22T01:27:14 Z daniel920712 CONSUL (info1cup19_consul) C++14
컴파일 오류
0 ms 0 KB
#include "grader.h"
#include "grader.h"
#include <map>
#include <time.h>
using namespace std;
map < int , int > all;
int how[1005];
void solve(int n)
{
    srand(time(NULL));
    all.clear();
    int i,t,big=0,xx=n,x,y;
    if(n<=50)
    {
        for(i=1;i<=n;i++)
        {
            t=kth(i);
            all[t]++;
            big=max(big,all[t]);

            if(all[t]>n/3)
            {
                say_answer(t);
                return;
            }
            if(big+(n-i)<=n/3)
            {
                say_answer(-1);
                return;
            }
        }
        say_answer(-1);
    }
    else
    {
        for(i=0;i<n;i++) how[i]=i+1;
        random_shuffle(how,how+n);
        for(i=0;i<30;i++)
        {
            x=kth(how[0]);
            if(cnt(x)>n/3) 
            {
                say_answer(x);
                return;
            }
            
        }
        say_answer(-1);
    }

}

Compilation message

consul.cpp: In function 'void solve(int)':
consul.cpp:37:9: error: 'random_shuffle' was not declared in this scope
   37 |         random_shuffle(how,how+n);
      |         ^~~~~~~~~~~~~~
consul.cpp:12:19: warning: unused variable 'xx' [-Wunused-variable]
   12 |     int i,t,big=0,xx=n,x,y;
      |                   ^~
consul.cpp:12:26: warning: unused variable 'y' [-Wunused-variable]
   12 |     int i,t,big=0,xx=n,x,y;
      |                          ^