답안 #976178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976178 2024-05-06T09:12:24 Z LucaIlie 커다란 상품 (IOI17_prize) C++17
컴파일 오류
0 ms 0 KB
#include "prize.h"

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

static const int max_q = 10000;
static int n;
static int query_count = 0;
static vector<int> g;
static vector<vector<int> > rank_count;

vector<int> ask(int i) {
    query_count++;
    if(query_count > max_q) {
        cerr << "Query limit exceeded" << endl;
        exit(0);
    }

    if(i < 0 || i >= n) {
        cerr << "Bad index: " << i << endl;
        exit(0);
    }

    vector<int> res(2);
    res[0] = rank_count[g[i] - 1][i + 1];
    res[1] = rank_count[g[i] - 1][n] - res[0];
    return res;
}

int main() {
    cin >> n;

    g.resize(n);
    for(int i = 0; i < n; i++) {
        cin >> g[i];
        if(g[i] < 1) {
            cerr << "Invalid rank " << g[i] << " at index " << i << endl;
            exit(0);
        }
    }

    int max_rank = *max_element(g.begin(), g.end());

    rank_count.resize(max_rank + 1, vector<int>(n + 1, 0));
    for(int r = 0; r <= max_rank; r++) {
        for(int i = 1; i <= n; i++) {
            rank_count[r][i] = rank_count[r][i - 1];
            if(g[i - 1] == r)
                rank_count[r][i]++;
        }
    }

    for(int i = 0; i <= n; i++)
        for(int r = 1; r <= max_rank; r++)
            rank_count[r][i] += rank_count[r - 1][i];

    int res = find_best(n);
    cout << res << endl << "Query count: " << query_count << endl;

    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccyqj8V6.o: in function `ask(int)':
grader.cpp:(.text+0x80): multiple definition of `ask(int)'; /tmp/cci1saJ9.o:prize.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccyqj8V6.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cci1saJ9.o:prize.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cci1saJ9.o: in function `main':
prize.cpp:(.text.startup+0x2c8): undefined reference to `find_best(int)'
/usr/bin/ld: /tmp/ccyqj8V6.o: in function `main':
grader.cpp:(.text.startup+0x98): undefined reference to `find_best(int)'
collect2: error: ld returned 1 exit status