Submission #293467

#TimeUsernameProblemLanguageResultExecution timeMemory
293467MuhammetaliHighway Tolls (IOI18_highway)C++11
Compilation error
0 ms0 KiB
#include "highway.h"
#include <bits/stdc++.h>
#define mp make_pair
#define sz(x) (int)(x).size()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define REP(i,a) for (int i = 0; i < (a); ++i)
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define trav(a,x) for (auto& a: x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
const int N=2e5+1;
template<class T>bool tmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool tmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
vl v,ab,coun;
vector<pair<ll,ll>> par[N];
ll a,b,jem[N]={INT_MAX};
void dfs(ll k,ll gos=0)
{
	REP(i,sz(par[k]))
	{
		if (jem[par[k][i].first]>gos+ab[v[par[k][i].second]])
		{
			jem[par[k][i].first]=gos+ab[v[par[k][i].second]];
			dfs(par[k][i].first,gos+ab[v[par[k][i].second]]);
		}
	}
}
void sum(ll toll)
{
	dfs(1);
	REP(i,coun.size())
	{
		if (coun[i]==1)continue;
		if (jem[coun[i]]!=toll)count.erase(i,1);
	}
}
void recur(int M,int sum=0)
{
	if (sum==M)
	{
		sum(ask(v));
		return;
	}
	FOR(i,0,1)
	{
		v.push_back(i);
		recur(M,sum+1);
		v.pop_back();
	}
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
	int M = U.size();
	ab.push_back(A);
	ab.push_back(B);
	bool bo[N]={0};
	REP(i,sz(U))
	{
		if (bo[U[i]]==0)
		{
			bo[U[i]]=1;
			coun.push_back(U[i]);
		}
		if (bo[V[i]]==0)
		{
			bo[V[i]]=1;
			coun.push_back(V[i]);
		}
		par[U[i]].push_back({V[i],i});
		par[V[i]].push_back({U[i],i});
	}
	recur(M);
	answer(count[0],count[1]);
}

Compilation message (stderr)

highway.cpp: In function 'void sum(ll)':
highway.cpp:14:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 | #define REP(i,a) for (int i = 0; i < (a); ++i)
      |                                    ^
highway.cpp:48:2: note: in expansion of macro 'REP'
   48 |  REP(i,coun.size())
      |  ^~~
highway.cpp:51:32: error: overloaded function with no contextual type information
   51 |   if (jem[coun[i]]!=toll)count.erase(i,1);
      |                                ^~~~~
highway.cpp: In function 'void recur(int, int)':
highway.cpp:58:11: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'vl' {aka 'std::vector<long long int>'}
   58 |   sum(ask(v));
      |           ^
In file included from highway.cpp:1:
highway.h:7:39: note: in passing argument 1 of 'long long int ask(const std::vector<int>&)'
    7 | long long ask(const std::vector<int> &w);
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^
highway.cpp:58:13: error: 'sum' cannot be used as a function
   58 |   sum(ask(v));
      |             ^
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:89:16: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   89 |  answer(count[0],count[1]);
      |                ^
highway.cpp:89:25: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   89 |  answer(count[0],count[1]);
      |                         ^