Submission #342574

#TimeUsernameProblemLanguageResultExecution timeMemory
342574MarcoMeijerHighway Tolls (IOI18_highway)C++14
Compilation error
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, m;
vi U, V, W;
vi adj[MX];
ll normal;
vi seq;
bitset<MX> visited;
int dst[MX];
int minLB, maxUB;

void fillAdj() {
    RE(i,U.size()) {
        adj[U[i]].push_back(i);
        adj[V[i]].push_back(i);
    }
}
void bfsSequence(vi init, int dist=-1) {
    minLB = -1, maxUB = -1;
    queue<int> q;
    visited.reset();
    FOR(u,init) q.push(u), visited[u]=1, dst[u]=0;
    while(!q.empty()) {
        int u=q.front(); q.pop();
        FOR(e,adj[u]) {
            if(visited[U[e]] && visited[V[e]]) continue;
            if(V[e] == u) swap(U[e], V[e]);
            int v=V[e];
            seq.push_back(e);
            q.push(v); visited[v] = 1;
            dst[v] = dst[u]+1;
            if(dst[v] == dist && minLB == -1) minLB = seq.size();
            if(dst[v] == dist) maxUB = seq.size();
        }
    }
    if(dist == -1) minLB=0, maxUB=m-1;
}
int binarySearchSeq() {
    int lb=minLB, ub=maxUB;
    while(lb != ub) {
        int mid=(lb+ub)/2;
        W.assign(m,1);
        REP(i,0,mid+1) W[seq[i]] = 0;
 
        if(ask(W) == normal) ub=mid;
        else                 lb=mid+1;
    }
    return V[seq[lb]];
}
int getEdgeOnPath() {
    int lb=0, ub=m-1;
    while(lb != ub) {
        int mid=(lb+ub)/2;
        W.assign(m,0);
        RE(i,mid+1) W[i] = 1;
        if(ask(W) == normal) lb=mid+1;
        else ub=mid;
    }
    return lb;
}

void find_pair(int N, vi _U, vi _V, int A, int B) {
    n=N; U=_U; V=_V; m=U.size();

    fillAdj();
    W.assign(m,0);
    normal = ask(W);

    int onPath = getEdgeOnPath();
    int v1 = U[onPath], v2 = V[onPath];
    seq.clear(); seq.push_back(onPath);
    bfsSequence({v1, v2});
    int s = binarySearchSeq();
    seq.clear(); bfsSequence({s}, normal/ll(A));
    int t = binarySearchSeq();
    answer(s,t);
}

#include "grader.cpp"

Compilation message (stderr)

In file included from highway.cpp:106:
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, W;
      |    ^
In file included from highway.cpp:106:
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, W;
      |       ^
In file included from highway.cpp:106:
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, W;
      |    ^
In file included from highway.cpp:106:
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, W;
      |       ^
In file included from highway.cpp:106:
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, W;
      |       ^
In file included from highway.cpp:106:
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, W;
      |    ^
In file included from highway.cpp:106:
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, W;
      |       ^