이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
#define debug printf
#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 , T ;
vector<int> toAsk , possible ;
ll oldVal , newVal , rad ;
bool marc[MAXN] ;
vector<Edge> adj[MAXN] ;
int edgePai[MAXN] ;
// --------------------------------
void dfs(int x , ll depth )
{
if( depth == rad ) possible.pb(x) ;
marc[x] = true ;
for(Edge e : adj[x])
if( !marc[e.j] )
{
edgePai[e.j] = e.id ;
dfs(e.j,depth+1) ;
}
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
m = U.size();
n = N ;
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) ;
}
oldVal = ask(toAsk) ;
rad = oldVal/A ;
edgePai[0] = -1 ;
dfs(0,0) ;
int l = 0 , r = possible.size() - 1 , mid , best = 0 ;
while(l<=r)
{
mid = (l+r)/2 ;
lp( i, l , mid+1 )
toAsk[ edgePai[possible[i]] ] = 1 ;
newVal = ask(toAsk) ;
lp(i,l,mid+1)
toAsk[ edgePai[possible[i]] ] = 0 ;
if( A < B ? newVal > oldVal : newVal < oldVal )
{
r = mid - 1;
best = mid ;
}
else l = mid+1 ;
}
T = possible[best] ;
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... |