제출 #342527

#제출 시각아이디문제언어결과실행 시간메모리
342527MarcoMeijerHighway Tolls (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;

// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define pb push_back
#define popb pop_back
#define fi first
#define se second

const int MX = 2e5;

int n, a, b;
vi U, V;
vi adj[MX];
vi seq, W;
ll normal;
int adjCnt[MX];

void fillAdj() {
    RE(i,U.size()) {
        adj[U[i]].push_back(i);
        adj[V[i]].push_back(i);
    }
}
void dfsSeq(int u, int p) {
    FOR(e,adj[u]) {
        if(V[e] == p || U[e] == p) continue;
        if(V[e] == u) swap(V[e], U[e]);
        int v = V[e];
        seq.push_back(e);
        dfsSeq(v, u);
    }
}
void findSeqLeaves() {
    seq.clear();
    queue<int> leaves;
    RE(i,n) adjCnt[i] = adj[i].size();
    RE(i,n) if(adjCnt[i] == 1) leaves.push(i);

    while(!leaves.empty()) {
        int u = leaves.front(); leaves.pop();
        FOR(e,adj[u]) {
            if(adjCnt[V[e]] == 0 || adjCnt[U[e]] == 0) continue;
            if(U[e] == u) swap(V[e], U[e]);
            int v = U[e];
            seq.push_back(e);
            adjCnt[v]--; adjCnt[u] = 0;
            if(adjCnt[v] == 1) leaves.push(v);
        }
    }
}

int binarySearchSeq() {
    int lb=0, ub=n-1;
    while(lb != ub) {
        int mid=(lb+ub)/2;
        W.assign(n-1,0);
        REP(i,0,mid+1) W[seq[i]] = 1;

        if(ask(W) == normal) lb=mid+1;
        else                 ub=mid;
    }
    return V[seq[lb]];
}

void findFromS(int S) {
    seq.clear();
    dfsSeq(S,-1);
    reverse(all(seq));

    int T = binarySearchSeq();
    answer(S,T);
}

void findAnsTree() {
    findSeqLeaves();
    int S = binarySearchSeq();
    findFromS(S);
}

void find_pair(int N, vi _U, vi _V, int A, int B) {
    n=N; U=_U; V=_V; a=A; b=B;

    fillAdj();
    W.assign(n-1,0);
    normal = ask(W);

    findAnsTree();
}

#include "grader.cpp"

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

In file included from highway.cpp:109:
grader.cpp: In function 'int main()':
grader.cpp:78:3: error: reference to 'U' is ambiguous
   78 |   U.resize(M);
      |   ^
grader.cpp:39:18: note: candidates are: 'std::vector<int> {anonymous}::U'
   39 | std::vector<int> U, V;
      |                  ^
highway.cpp:31:4: note:                 'vi U'
   31 | vi U, V;
      |    ^
In file included from highway.cpp:109:
grader.cpp:79:3: error: reference to 'V' is ambiguous
   79 |   V.resize(M);
      |   ^
grader.cpp:39:21: note: candidates are: 'std::vector<int> {anonymous}::V'
   39 | std::vector<int> U, V;
      |                     ^
highway.cpp:31:7: note:                 'vi V'
   31 | vi U, V;
      |       ^
In file included from highway.cpp:109:
grader.cpp:81:5: error: reference to 'U' is ambiguous
   81 |     U[i] = read_int() ^ 781291;
      |     ^
grader.cpp:39:18: note: candidates are: 'std::vector<int> {anonymous}::U'
   39 | std::vector<int> U, V;
      |                  ^
highway.cpp:31:4: note:                 'vi U'
   31 | vi U, V;
      |    ^
In file included from highway.cpp:109:
grader.cpp:83:3: error: reference to 'V' is ambiguous
   83 |   V.resize(M);
      |   ^
grader.cpp:39:21: note: candidates are: 'std::vector<int> {anonymous}::V'
   39 | std::vector<int> U, V;
      |                     ^
highway.cpp:31:7: note:                 'vi V'
   31 | vi U, V;
      |       ^
In file included from highway.cpp:109:
grader.cpp:85:5: error: reference to 'V' is ambiguous
   85 |     V[i] = read_int() ^ 691753;
      |     ^
grader.cpp:39:21: note: candidates are: 'std::vector<int> {anonymous}::V'
   39 | std::vector<int> U, V;
      |                     ^
highway.cpp:31:7: note:                 'vi V'
   31 | vi U, V;
      |       ^
In file included from highway.cpp:109:
grader.cpp:91:16: error: reference to 'U' is ambiguous
   91 |   find_pair(N, U, V, A, B);
      |                ^
grader.cpp:39:18: note: candidates are: 'std::vector<int> {anonymous}::U'
   39 | std::vector<int> U, V;
      |                  ^
highway.cpp:31:4: note:                 'vi U'
   31 | vi U, V;
      |    ^
In file included from highway.cpp:109:
grader.cpp:91:19: error: reference to 'V' is ambiguous
   91 |   find_pair(N, U, V, A, B);
      |                   ^
grader.cpp:39:21: note: candidates are: 'std::vector<int> {anonymous}::V'
   39 | std::vector<int> U, V;
      |                     ^
highway.cpp:31:7: note:                 'vi V'
   31 | vi U, V;
      |       ^