답안 #269564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
269564 2020-08-17T07:52:12 Z PeppaPig 최후의 만찬 (IOI12_supper) C++14
컴파일 오류
0 ms 0 KB
#include "advisor.h"
#include <bits/stdc++.h>

#define pii pair<int, int>
#define x first
#define y second

using namespace std;

static const int N = 1e5 + 5;

static int t[N];

static void update(int x, int k) {
    for(int i = x + 1; i < N; i += i & -i)
        t[i] += k;
}

static int query(int x, int ret = 0) {
    for(int i = x + 1; i; i -= i & -i)
        ret += t[i];
    return ret;
}

static int col[N];

void ComputeAdvice(int *C, int n, int k, int M) {
    for(int i = 0; i < n; i++) col[i] = lower_bound(C, C + n, i) - C;

    priority_queue<pii> Q;
    for(int i = 0; i < k; i++) update(i, 1), Q.emplace(col[i], i);
    for(int i = 0; i < n; i++) {
        if(query(C[i]) - query(C[i] - 1) == 1)
            for(int j = 0; j < 15; j++) WriteAdvice(0);
        else {
            pii now = Q.top(); Q.pop();
            col[now.y] = lower_bound(C + i + 1, C + n, now.y) - C;
            int idx = query(now.y); 
            for(int j = 0; j < 15; j++) WriteAdvice(idx >> j & 1);
            col[C[i]] = lower_bound(C + i + 1, C + n, C[i]) - C;
            Q.emplace(col[C[i]], C[i]);
        }
    }
}
#include "advisor.h"
#include <bits/stdc++.h>

#define pii pair<int, int>
#define x first
#define y second

using namespace std;

static const int N = 1e5 + 5;

static int t[N];

static void update(int x, int k) {
    for(int i = x + 1; i < N; i += i & -i)
        t[i] += k;
}

static int query(int x, int ret = 0) {
    for(int i = x + 1; i; i -= i & -i)
        ret += t[i];
    return ret;
}

static int col[N];

void ComputeAdvice(int *C, int n, int k, int M) {
    for(int i = 0; i < n; i++) col[i] = lower_bound(C, C + n, i) - C;

    priority_queue<pii> Q;
    for(int i = 0; i < k; i++) update(i, 1), Q.emplace(col[i], i);
    for(int i = 0; i < n; i++) {
        if(query(C[i]) - query(C[i] - 1) == 1)
            for(int j = 0; j < 15; j++) WriteAdvice(0);
        else {
            pii now = Q.top(); Q.pop();
            col[now.y] = lower_bound(C + i + 1, C + n, now.y) - C;
            int idx = query(now.y); 
            for(int j = 0; j < 15; j++) WriteAdvice(idx >> j & 1);
            col[C[i]] = lower_bound(C + i + 1, C + n, C[i]) - C;
            Q.emplace(col[C[i]], C[i]);
        }
    }
}

Compilation message

/tmp/ccnWKkoJ.o: In function `ComputeAdvice(int*, int, int, int)':
assistant.cpp:(.text+0x1c3): undefined reference to `WriteAdvice(unsigned char)'
assistant.cpp:(.text+0x2cb): undefined reference to `WriteAdvice(unsigned char)'
/tmp/cciiIbjp.o: In function `main':
assistant_grader.cpp:(.text.startup+0x21f): undefined reference to `Assist(unsigned char*, int, int, int)'
collect2: error: ld returned 1 exit status