Submission #75185

#TimeUsernameProblemLanguageResultExecution timeMemory
75185tmwilliamlin168Highway Tolls (IOI18_highway)C++14
51 / 100
290 ms8888 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int mxN=9e4; int n, qu[mxN], qt, p[mxN]; vector<int> eu, ev, adj[mxN], w; ll ba; int bfs(int s) { qt=0; qu[qt++]=s; memset(p, -1, 4*n); p[s]=-2; for(int i=0; i<n; ++i) { int u=qu[i]; for(int e : adj[u]) { int v=u^eu[e]^ev[e]; if(p[v]==-1) { p[v]=e; qu[qt++]=v; } } } int lb=1, rb=n-1; while(lb<=rb) { int mb=(lb+rb)/2; fill(w.begin(), w.end(), 0); for(int i=mb; i<n; ++i) w[p[qu[i]]]=1; if(ask(w)>ba) lb=mb+1; else rb=mb-1; } return qu[rb]; } void find_pair(int n2, vector<int> u, vector<int> v, int a, int b) { n=n2, eu=u, ev=v; if(u.size()!=n-1) { answer(1, 3); return; } w.resize(n-1); ba=ask(w); for(int i=0; i<n-1; ++i) { adj[u[i]].push_back(i); adj[v[i]].push_back(i); } int s=bfs(0), t=bfs(s); answer(s, t); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:43:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(u.size()!=n-1) {
     ~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...