제출 #250327

#제출 시각아이디문제언어결과실행 시간메모리
250327Osama_Alkhodairy통행료 (IOI18_highway)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
//~ #include "highway.h"
#include "grader.cpp"
using namespace std;
#define ll long long

int n, m;
vector <pair <int, int> > es, g[90001];
ll light;
int dist;

int find(int root, bool b){
    vector <bool> vis(n);
    queue <int> ready;
    vector <int> depth(n);
    ready.push(root);
    vector <int> nodes;
    vis[root] = 1;
    while(ready.size()){
        int node = ready.front();
        ready.pop();
        nodes.push_back(node);
        for(auto &i : g[node]){
            if(vis[i.first]) continue;
            vis[i.first] = 1;
            depth[i.first] = depth[node] + 1;
            ready.push(i.first);
        }
    }
    if(b){
        while(depth[nodes.back()] != dist){
            nodes.pop_back();
        }
    }
    reverse(nodes.begin(), nodes.end());
    if(b){
        while(depth[nodes.back()] != dist){
            nodes.pop_back();
        }
    }
    while(depth[nodes.back()] < dist / 2){
        nodes.pop_back();
    }
    int l = 0, r = (int)nodes.size() - 1;
    while(l <= r){
        int mid = (l + r) / 2;
        vector <int> check(m), vis(m);
        for(int i = 0 ; i <= mid ; i++){
            for(auto &j : g[nodes[i]]){
                if(vis[j.second]) continue;
                vis[j.second] = 1;
                check[j.second] = 1;
            }
        }
        if(ask(check) != light) r = mid - 1;
        else l = mid + 1;
    }
    return nodes[l];
}
void find_pair(int N, std::vector<int> u, std::vector<int> v, int a, int b) {
    n = N;
    m = u.size();
    for(int i = 0 ; i < m ; i++){
        g[u[i]].push_back(make_pair(v[i], i));
        g[v[i]].push_back(make_pair(u[i], i));
        es.push_back(make_pair(u[i], v[i]));
    }
    light = ask(vector <int>(m, 0));
    dist = light / a;
    int l = 0, r = m - 1;
    while(l <= r){
        int mid = (l + r) / 2;
        vector <int> check(m);
        for(int i = 0 ; i <= mid ; i++){
            check[i] = 1;
        }
        if(ask(check) != light) r = mid - 1;
        else l = mid + 1;
    }
    int root = es[l].first;
    int s = find(root, 0);
    int t = find(s, 1);
    answer(s, t);
}

컴파일 시 표준 에러 (stderr) 메시지

/tmp/ccVLSWQJ.o: In function `ask(std::vector<int, std::allocator<int> > const&)':
grader.cpp:(.text+0x70): multiple definition of `ask(std::vector<int, std::allocator<int> > const&)'
/tmp/ccyiPm1I.o:highway.cpp:(.text+0xa0): first defined here
/tmp/ccVLSWQJ.o: In function `answer(int, int)':
grader.cpp:(.text+0x1e0): multiple definition of `answer(int, int)'
/tmp/ccyiPm1I.o:highway.cpp:(.text+0x210): first defined here
/tmp/ccVLSWQJ.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccyiPm1I.o:highway.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status