Submission #292403

#TimeUsernameProblemLanguageResultExecution timeMemory
292403zoooma13Highway Tolls (IOI18_highway)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "highway.h" #include "grader.cpp" using namespace std; vector<vector <pair<int ,int>>> adj; vector <pair<int ,int>> ver; void dfs(int u ,int p=-1 ,int f=-1){ for(auto&e : adj[u]) if(e.first != p) dfs(e.first ,u ,e.second); ver.push_back({u ,f}); } void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { int M = U.size(); adj.resize(N); for(int i=0; i<M; i++){ adj[U[i]].push_back({V[i] ,i}); adj[V[i]].push_back({U[i] ,i}); } long long emp = ask(vector<int>(M ,0)); int st = 0 ,en = M-1 ,mid; while(st <= en){ mid = (st+en)>>1; vector <int> t(mid+1 ,1); t.resize(M); if(ask(t) != emp) en = mid-1; else st = mid+1; } int root = U[st]; vector <int> intree(M ,1); queue <int> q{{root}}; vector <bool> vis(N); vis[root] = 1; vector <vector<pair<int ,int>>> newadj(N); while(!q.empty()){ int u = q.front(); q.pop(); for(auto&e : adj[u]) if(!vis[e.first]){ q.push(e.first); vis[e.first] = 1; intree[e.second] = 0; newadj[u].push_back({e.first ,e.second}); newadj[e.first].push_back({u ,e.second}); } } swap(adj ,newadj); int S ,T; ver.clear() ,dfs(root) ,ver.pop_back(); st = 0 ,en = N-1 ,mid; while(st <= en){ mid = (st+en)>>1; vector <int> t = intree; for(int i=st; i<=mid; i++) t[ ver[i].second ] = 1; if(ask(t) != emp) en = mid-1; else st = mid+1; } S = ver[st].first; ver.clear() ,dfs(S) ,ver.pop_back(); st = 0 ,en = N-1 ,mid; while(st <= en){ mid = (st+en)>>1; vector <int> t = intree; for(int i=st; i<=mid; i++) t[ ver[i].second ] = 1; if(ask(t) != emp) en = mid-1; else st = mid+1; } T = ver[st].first; answer(S ,T); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:58:26: warning: right operand of comma operator has no effect [-Wunused-value]
   58 |     st = 0 ,en = N-1 ,mid;
      |                          ^
highway.cpp:71:26: warning: right operand of comma operator has no effect [-Wunused-value]
   71 |     st = 0 ,en = N-1 ,mid;
      |                          ^
/tmp/ccUXFRF1.o: In function `ask(std::vector<int, std::allocator<int> > const&)':
grader.cpp:(.text+0xa0): multiple definition of `ask(std::vector<int, std::allocator<int> > const&)'
/tmp/cc9alEx0.o:highway.cpp:(.text+0xa0): first defined here
/tmp/ccUXFRF1.o: In function `answer(int, int)':
grader.cpp:(.text+0x210): multiple definition of `answer(int, int)'
/tmp/cc9alEx0.o:highway.cpp:(.text+0x210): first defined here
/tmp/ccUXFRF1.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc9alEx0.o:highway.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status