답안 #514836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
514836 2022-01-18T14:41:25 Z andrei_boaca 최후의 만찬 (IOI12_supper) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "assistant.h"
#include "advisor.h"

using namespace std;
typedef pair<int,int> pii;
bool useful[200005];
int isthere[200005];
multiset<int> s;
deque<int> poz[200005];
int INF=1e9;
void ComputeAdvice(int *C, int N, int K, int M)
{
    for(int i=0;i<K;i++)
        poz[i].push_back(i);
    for(int j=0;j<N;j++)
        poz[C[j]].push_back(j+K);
    for(int i=0;i<=N+K;i++)
        useful[i]=0;
    for(int i=0;i<K;i++)
    {
        isthere[i]=i+1;
        poz[i].pop_front();
        if(poz[i].empty())
            s.insert(INF);
        else
            s.insert(poz[i].front());
    }
    for(int i=0;i<N;i++)
    {
        int nr=C[i];
        if(isthere[nr])
        {
            useful[isthere[nr]-1]=1;
            int p=poz[nr].front();
            if(s.find(p)!=s.end())
                s.erase(s.find(p));
        }
        else
        {
            auto it=prev(s.end());
            s.erase(it);
            int p=(*it);
            p-=K;
            if(p<N&&p>=0)
                isthere[C[p]]=0;
        }
        isthere[nr]=poz[nr].front()+1;
        poz[nr].pop_front();
        if(poz[nr].empty())
            s.insert(INF);
        else
            s.insert(poz[nr].front());
    }
    for(int i=0;i<N+K;i++)
        WriteAdvice(useful[i]);
}



set<pii> buffer;
int there[200005];
void Assist(unsigned char *A, int N, int K, int R)
{
    for(int i=0;i<K;i++)
    {
        int x=A[i]-'0';
        if(x==0)
            x=-1;
        buffer.insert({x,i});
        there[i]=x;
    }
    for(int i=K;i<N+K;i++)
    {
        int nr=GetRequest();
        if(there[nr])
        {
            if(buffer.find({there[nr],nr})!=buffer.end())
            buffer.erase({there[nr],nr});
        }
        else
        {
            auto it=buffer.begin();
            int nr=(*it).second;
            buffer.erase(it);
            there[nr]=0;
            PutBack(nr);
        }
        int x=A[i]-'0';
        if(x==0)
            x=-1;
        there[nr]=x;
        buffer.insert({x,nr});
    }
}



    

Compilation message

/usr/bin/ld: /tmp/cc6LdXCG.o: in function `Assist(unsigned char*, int, int, int)':
advisor.cpp:(.text+0x2e1): undefined reference to `GetRequest()'
/usr/bin/ld: advisor.cpp:(.text+0x48d): undefined reference to `PutBack(int)'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/ccipTUDq.o: in function `main':
assistant_grader.cpp:(.text.startup+0x21e): undefined reference to `Assist(unsigned char*, int, int, int)'
collect2: error: ld returned 1 exit status