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>
#define debug //
#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
const int MAXN = 9e4+ 10 ;
const int MAXM = 13e4+10 ;
using namespace std ;
struct Edge
{
int j , id ;
Edge(int j = 0 , int id = 0)
: j(j) , id(id) {}
} ;
int n , m , S = 0 , T ;
ll dist , tot ;
int v[MAXM] , u[MAXM] ;
vector<int> toAsk ;
vector<Edge> adj[MAXN] ;
pii edge[MAXM] ;
bool marc[MAXM] ;
// --------------------------------
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
m = U.size();
n = N ;
lp(i,0,m) u[i] = U[i] , v[i] = V[i] ;
lp(i,0,m)
{
int a = u[i] , b = v[i] ;
adj[a].pb(Edge(b,i)) ;
adj[b].pb(Edge(a,i)) ;
toAsk.pb(0) ;
edge[i] = mk(a,b) ;
}
tot = ask(toAsk) ;
int cur = 0 ;
while(true)
{
int l = 0 , r = adj[cur].size() - 1 , best = -1 ;
while( l <= r )
{
int mid = (l+r)/2 ;
lp(i,0,m) toAsk[i] = 0 ;
lp(i , l , mid+1 )
if(!marc[ adj[cur][i].id ])
{
toAsk[ adj[cur][i].id ] = 1 ;
marc[ adj[cur][i].id ] = true ;
}
ll newTot = ask(toAsk) ;
if( A < B ? newTot > tot : newTot < tot ) { best = mid ; r = mid-1 ; }
else l = mid+1 ;
}
if(best == -1) { T = cur ; break ; }
cur = adj[cur][best].j ;
}
answer(S,T) ;
}
# | 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... |