제출 #1365823

#제출 시각아이디문제언어결과실행 시간메모리
1365823ivaziva통행료 (IOI18_highway)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "highway.h"

using namespace std;

#define MAXN 90001

int n,m,a,b;
vector<pair<int,int>> adj[MAXN];
pair<int,int> parent[MAXN];
int dist[MAXN];
vector<int> nodes[MAXN];
vector<int> state;

void dfs(int node,int pret,int edge,int depth)
{
	parent[node]={pret,edge};dist[node]=depth;nodes[depth].push_back(node);
	for (pair<int,int> sled:adj[node])
	{
		if (sled.first!=pret) dfs(sled.first,node,sled.second,depth+1);
	}
}

void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B)
{
	n=N;m=(int)U.size();a=A;b=B;
	for (int i=0;i<m;i++) {adj[U[i]].push_back({V[i],i});adj[V[i]].push_back({U[i],i});}
	if (m!=n-1) {answer(0,0);return;}
	dfs(0,-1,-1,0);for (int i=0;i<m;i++) state.push_back(0);
	int distancija=((long long)ask())/a;
	int maxdist=0;for (int node=0;node<n;node++) maxdist=max(maxdist,dist[node]);
	int l=1,r=maxdist,rez=0;
	while (l<=r)
	{
		int mid=(l+r)/2;
		for (int distanca=0;distanca<=mid;distanca++)
		{
			for (int node:nodes[distanca])
			{
				if (parent[node].second!=-1) state[parent[node].second]=1;
			}
		}
		long long curr=ask();
		if (curr==(long long)a*distancija) {rez=mid;l=mid+1;}
		else r=mid-1;
		for (int distanca=0;distanca<=mid;distanca++)
		{
			for (int node:nodes[distanca])
			{
				if (parent[node].second!=-1) state[parent[node].second]=0;
			}
		}
	}
	int depthlca=rez;
	l=depthlca+1,r=maxdist,rez=depthlca;
	while (l<=r)
	{
		int mid=(l+r)/2;
		for (int distanca=0;distanca<=mid;distanca++)
		{
			for (int node:nodes[distanca])
			{
				if (parent[node].second!=-1) state[parent[node].second]=1;
			}
		}
		long long curr=ask();
		if (curr==(long long)b*distancija) {rez=mid;r=mid-1;}
		else l=mid+1;
		for (int distanca=0;distanca<=mid;distanca++)
		{
			for (int node:nodes[distanca])
			{
				if (parent[node].second!=-1) state[parent[node].second]=0;
			}
		}
	}
	int depthnode1=rez;
	int depthnode2=2*depthlca+distancija-depthnode1;
	if (depthnode1==depthnode2)
	{
		l=0,r=(int)nodes[depthnode1].size()-1,rez=-1;
		while (l<=r)
		{
			int mid=(l+r)/2;
			for (int pos=mid;pos<(int)nodes[depthnode1].size();pos++)
			{
				int node=nodes[depthnode1][pos];
				if (parent[node].second!=-1) state[parent[node].second]=1;
		    }
		    long long sol=ask();
		    if (sol==(long long)a*distancija+2*(b-a)) {rez=mid;r=mid-1;}
		    else l=mid+1;
		    for (int pos=mid;pos<(int)nodes[depthnode1].size();pos++)
			{
				int node=nodes[depthnode1][pos];
				if (parent[node].second!=-1) state[parent[node].second]=0;
		    }
		}
		int node1=nodes[depthnode1][rez];
		l=rez+1,r=(int)nodes[depthnode1].size()-1;rez=-1;
		while (l<=r)
		{
			int mid=(l+r)/2;
			for (int pos=mid;pos<(int)nodes[depthnode1].size();pos++)
			{
				int node=nodes[depthnode1][pos];
				if (parent[node].second!=-1) state[parent[node].second]=1;
		    }
		    long long sol=ask();
		    if (sol==(long long)a*distancija+(b-a)) {rez=mid;r=mid-1;}
		    else l=mid+1;
		    for (int pos=mid;pos<(int)nodes[depthnode1].size();pos++)
			{
				int node=nodes[depthnode1][pos];
				if (parent[node].second!=-1) state[parent[node].second]=0;
		    }
	    }
	    int node2=nodes[depthnode1][rez];
	    answer(node1,node2);return;
	}
	l=0,r=(int)nodes[depthnode1].size()-1,rez=-1;
	while (l<=r)
	{
		int mid=(l+r)/2;
		for (int pos=mid;pos<(int)nodes[depthnode1].size();pos++)
		{
			int node=nodes[depthnode1][pos];
			if (parent[node].second!=-1) state[parent[node].second]=1;
		}
		long long sol=ask();
		if (sol==(long long)a*distancija+(b-a)) {rez=mid;r=mid-1;}
		else l=mid+1;
		for (int pos=mid;pos<(int)nodes[depthnode1].size();pos++)
		{
			int node=nodes[depthnode1][pos];
			if (parent[node].second!=-1) state[parent[node].second]=0;
		}
	}
	int node1=nodes[depthnode1][rez];
	if (depthnode2==depthlca)
	{
		int node2=node1;int number=0;
		while (number<distancija) {node2=parent[node2].first;number++;}
		answer(node1,node2);return;
    }
    l=0,r=(int)nodes[depthnode2].size()-1,rez=-1;
	while (l<=r)
	{
		int mid=(l+r)/2;
		for (int pos=mid;pos<(int)nodes[depthnode2].size();pos++)
		{
			int node=nodes[depthnode2][pos];
			if (parent[node].second!=-1) state[parent[node].second]=1;
		}
		long long sol=ask();
		if (sol==(long long)a*distancija+(b-a)) {rez=mid;r=mid-1;}
		else l=mid+1;
		for (int pos=mid;pos<(int)nodes[depthnode2].size();pos++)
		{
			int node=nodes[depthnode2][pos];
			if (parent[node].second!=-1) state[parent[node].second]=0;
		}
	}
	int node2=nodes[depthnode2][rez];
	answer(node1,node2);
}

컴파일 시 표준 에러 (stderr) 메시지

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:30:39: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
   30 |         int distancija=((long long)ask())/a;
      |                                    ~~~^~
In file included from highway.cpp:2:
highway.h:7:11: note: declared here
    7 | long long ask(const std::vector<int> &w);
      |           ^~~
highway.cpp:43:35: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
   43 |                 long long curr=ask();
      |                                ~~~^~
highway.h:7:11: note: declared here
    7 | long long ask(const std::vector<int> &w);
      |           ^~~
highway.cpp:66:35: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
   66 |                 long long curr=ask();
      |                                ~~~^~
highway.h:7:11: note: declared here
    7 | long long ask(const std::vector<int> &w);
      |           ^~~
highway.cpp:90:38: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
   90 |                     long long sol=ask();
      |                                   ~~~^~
highway.h:7:11: note: declared here
    7 | long long ask(const std::vector<int> &w);
      |           ^~~
highway.cpp:109:38: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
  109 |                     long long sol=ask();
      |                                   ~~~^~
highway.h:7:11: note: declared here
    7 | long long ask(const std::vector<int> &w);
      |           ^~~
highway.cpp:130:34: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
  130 |                 long long sol=ask();
      |                               ~~~^~
highway.h:7:11: note: declared here
    7 | long long ask(const std::vector<int> &w);
      |           ^~~
highway.cpp:155:34: error: too few arguments to function 'long long int ask(const std::vector<int>&)'
  155 |                 long long sol=ask();
      |                               ~~~^~
highway.h:7:11: note: declared here
    7 | long long ask(const std::vector<int> &w);
      |           ^~~