Submission #116507

# Submission time Handle Problem Language Result Execution time Memory
116507 2019-06-12T16:18:20 Z MvC Highway Tolls (IOI18_highway) C++14
Compilation error
0 ms 0 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#include "highway.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const ll nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,i,x,y,viz[nmax],l,r,mid,ub,lb;
ll d,d1,f,s;
vector<pair<int,int> >ord,a[nmax],nw;
vector<int>vc;
void dfs(int x,int y)
{
	if(viz[x])return;
	if(y!=-1)ord.pb(mkp(x,y));
	viz[x]=1;
	for(int i=0;i<a[x].size();i++)dfs(a[x][i].fr,a[x][i].sc);
}
void dfs1(int x,int l,int y)
{
	if(viz[x])return;
	viz[x]=1;
	if(l==d/f)nw.pb(mkp(x,y));
	for(int i=0;i<a[x].size();i++)dfs1(a[x][i].fr,l+1,a[x][i].sc);
}
int ok(int x)
{
	int i;
	for(i=0;i<x;i++)vc[ord[i].sc]=1;
	for(;i<n-1;i++)vc[ord[i].sc]=0;
	return (ask()<d1);
}
int ok1(int x)
{
	int i;
	for(i=0;i<n-1;i++)vc[i]=0;
	for(i=0;i<x;i++)vc[nw[i].sc]=1;
	return (ask()==d);
}
void find_pair(int N,vector<int>U,vector<int>V,int A,int B)
{
	n=N;
	for(i=0;i<n-1;i++)
	{
		x=U[i],y=V[i];
		a[x].pb(mkp(y,i));
		a[y].pb(mkp(x,i));
	}
	f=A,s=B;
	dfs(1,-1);
	for(i=0;i<n-1;i++)vc.pb(0);
	d=ask();
	d1=(d/f)*s;
	l=1,r=n-1;
	while(l<=r)
	{
		mid=(l+r)/2;
		if(ok(mid))l=mid+1;
		else ub=mid,r=mid-1;
	}
	memset(viz,0,sizeof(viz));
	dfs1(ord[ub-1].fr,0,-1);
	l=1,r=(int)nw.size();
	while(l<=r)
	{
		mid=(l+r)/2;
		if(ok1(mid))l=mid+1;
		else lb=mid,r=mid-1;
	}
	answer(nw[lb-1].fr,ord[ub-1].fr);
}

Compilation message

highway.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
highway.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
highway.cpp: In function 'void dfs(int, int)':
highway.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a[x].size();i++)dfs(a[x][i].fr,a[x][i].sc);
              ~^~~~~~~~~~~~
highway.cpp: In function 'void dfs1(int, int, int)':
highway.cpp:38:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a[x].size();i++)dfs1(a[x][i].fr,l+1,a[x][i].sc);
              ~^~~~~~~~~~~~
highway.cpp: In function 'int ok(int)':
highway.cpp:45:14: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
  return (ask()<d1);
              ^
In file included from highway.cpp:5:0:
highway.h:7:11: note: declared here
 long long ask(const std::vector<int> &w);
           ^~~
highway.cpp: In function 'int ok1(int)':
highway.cpp:52:14: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
  return (ask()==d);
              ^
In file included from highway.cpp:5:0:
highway.h:7:11: note: declared here
 long long ask(const std::vector<int> &w);
           ^~~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:66:8: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
  d=ask();
        ^
In file included from highway.cpp:5:0:
highway.h:7:11: note: declared here
 long long ask(const std::vector<int> &w);
           ^~~