This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |