답안 #120284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120284 2019-06-24T06:37:12 Z 이온조(#2949) 통행료 (IOI18_highway) C++14
컴파일 오류
0 ms 0 KB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int n, M;
long long ori;
vector<pii> adj[90009];
int D[90009];

int any(vector<int> S) {
    int K = S.size();
    int l = 0, r = K-1;
    while(l <= r) {
        if(l == r) return S[l];
        int m = l+r >> 1;
        vector<int> W(M, 0);
        for(int i=0; i<=m; i++) for(auto& it: adj[S[i]]) W[it.second] = 1;
        if(ask(W) != ori) r = m-1;
        else l = m+1;
    }
    return S[r+1];
}

vector<int> f(int root) {
    int c = 1;
    for(int i=0; i<n; i++) D[i] = 0;
    queue<int> que; que.push(root); D[root] = 1;
    while(que.size()) {
        int sz = que.size();
        while(sz--) {
            int now; now = que.front(); que.pop();
            for(auto& it: adj[now]) {
                if(!D[it.first]) {
                    D[it.first] = c+1;
                    que.push(it.first);
                }
            }
        }
        ++c;
    }
    vector<int> S;
    for(int i=0; i<n; i++) S.push_back(i);
    sort(S.begin(), S.end(), [&](int P, int Q) {return D[P] > D[Q];});
    return S;
}

void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
    n = N; M = U.size();
    for(int i=0; i<M; i++) {
        adj[U[i]].push_back({V[i], i});
        adj[V[i]].push_back({U[i], i});
    }
    vector<int> W(M, 0), S = f(0); ori = ask(W);
    reverse(S.begin(), S.end());
    int P = any(f(any()));
    int Q = any(f(P));
    answer(P, Q);
}

Compilation message

highway.cpp: In function 'int any(std::vector<int>)':
highway.cpp:16:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         int m = l+r >> 1;
                 ~^~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:56:23: error: too few arguments to function 'int any(std::vector<int>)'
     int P = any(f(any()));
                       ^
highway.cpp:11:5: note: declared here
 int any(vector<int> S) {
     ^~~