Submission #136456

# Submission time Handle Problem Language Result Execution time Memory
136456 2019-07-25T10:28:16 Z amiratou Highway Tolls (IOI18_highway) C++14
0 / 100
24 ms 2312 KB
#include "highway.h"
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
vector<vector<ii> > vec;
vector<int> query;
vector<ii> target;
ll dist,a,b;
void dfs(int node,ll d,int high,int p){
	if(d*a==dist){
		target.pb(ii(high,node));
		return;
	}
	for(auto child:vec[node])
		if(child.fi!=p)
			dfs(child.fi,d+1,child.se,node);
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
	int M = U.size();
	a=A,b=B;
	vec.resize(N);
	query.resize(M);
	for (int i = 0; i < M; ++i)
	{
		vec[U[i]].pb(ii(V[i],i));
		vec[V[i]].pb(ii(U[i],i));
	}
	fill(query.begin(),query.end(),0);
	dist=ask(query);
	dfs(0,0,-1,0);
	sort(target.begin(),target.end());
	int l=0,r=(int)target.size()-1,ans=0;
	for (int i = 0; i <= r; ++i)
	{
		cerr<<target[i].se<<" ";
	}
	cerr<<"\n";
	while(l<=r){
		int med=(l+r)>>1;
		fill(query.begin(),query.end(),0);
		for (int i = l; i <= med; ++i)
			query[target[i].fi]=1;
		ll check=ask(query);
		if(check!=dist){
			ans=med;
			r=med-1;
		}
		else l=med+1;
	}
	answer(0, target[ans].se);
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 248 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1164 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 400 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 2312 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1260 KB DO NOT PRINT ANYTHING TO STANDARD OUTPUT
2 Halted 0 ms 0 KB -