답안 #718876

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718876 2023-04-05T04:24:20 Z lam 최후의 만찬 (IOI12_supper) C++14
컴파일 오류
0 ms 0 KB
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
typedef pair<int,int> ii;
#define ff first
#define ss second
int n,m,k;
int type[maxn];
void Assist(unsigned char *A, int N, int K, int R) {

    n=N;
    k=K;
    m=n+k;
    multiset<ii> ms;
    fill_n(type,m+1,0);
    for (int i=1; i<=k; i++)
    {
        char x = A[i-1];
        if (x=='1') type[i-1] = 2;
        else type[i-1] = 1;
        ms.insert({type[i-1],i-1});
    };
    for (int i=1; i<=n; i++)
    {
        int x=GetRequest();
        char c = A[k+i-1];
        if (type[x]!=0)
        {
            ms.erase(ms.find({type[x],x}));
            type[x] = (c=='1')+1;
            ms.insert({type[x],x});
        }
        else
        {
            auto r = ms.end(); r--;
            PutBack(r->ss);
            type[r->ss] = 0;
            ms.erase(r);
            type[x] = (c=='1')+1;
            ms.insert({type[x],x});
        }
    }

}
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
#define ff first
#define ss second
map<int,int> mp;
const int maxn = 2e5 + 10;
int n,k,m;
int a[maxn],pre[maxn],id[maxn],type[maxn];
int xoa[maxn];
void ComputeAdvice(int *C, int N, int K, int M) {
    n=N; k=K;
    for (int i=1; i<=k; i++) a[i]=i-1;
    for (int i=1; i<=n; i++) a[i+k] = C[i-1];
    mp.clear();
    m=n+k;
    for (int i=m; i>=1; i--)
    {
        if (!mp[a[i]]) pre[i]=n+1;
        else pre[i]=mp[a[i]];
        mp[a[i]]=i;
    }
    fill_n(id,m+1,0);
    fill_n(type,m+1,0);
    multiset<ii> ms;
    for (int i=1; i<=k; i++) ms.insert({pre[i],i}),id[a[i]]=i;
    for (int i=k+1; i<=m; i++)
    {
        if (id[a[i]]!=0)
        {
            int x=id[a[i]];
            ms.erase(ms.find({pre[x],x}));
            type[x] = 1;
            id[a[i]]=i;
            ms.insert({pre[i],i});
            continue;
        }
        auto it = ms.end(); it--;
        xoa[i] = it->ss;
        ms.erase(it);
        ms.insert({pre[i],i});
        type[xoa[i]] = 2;
        id[a[xoa[i]]] = 0;
        id[a[i]] = i;
    }
    for (int i=0; i<n; i++) if (id[i]!=0) type[id[i]] = 2;
    for (int i=1; i<=m; i++) if (type[i]==2) WriteAdvice(1);
    else WriteAdvice(0);
}

Compilation message

/usr/bin/ld: /tmp/ccNGr1i6.o: in function `Assist(unsigned char*, int, int, int)':
advisor.cpp:(.text+0x2e1): undefined reference to `GetRequest()'
/usr/bin/ld: advisor.cpp:(.text+0x3ef): undefined reference to `PutBack(int)'
/usr/bin/ld: /tmp/ccG0T1F6.o: in function `main':
advisor_grader.cpp:(.text.startup+0xe6): undefined reference to `ComputeAdvice(int*, int, int, int)'
collect2: error: ld returned 1 exit status

/usr/bin/ld: /tmp/ccIRRGQR.o: in function `ComputeAdvice(int*, int, int, int)':
assistant.cpp:(.text+0x9c3): undefined reference to `WriteAdvice(unsigned char)'
/usr/bin/ld: assistant.cpp:(.text+0x9e0): undefined reference to `WriteAdvice(unsigned char)'
/usr/bin/ld: /tmp/cculmyxS.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