Submission #293955

#TimeUsernameProblemLanguageResultExecution timeMemory
293955MuhammetaliHighway Tolls (IOI18_highway)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
#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;
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;}
ll san1,san2,res1,res2;
vl U,V;
vpl roads[1000],saher1,saher2,nodes[1000];
bool vis[1000];
void find()
{
	sort(saher1.begin(),saher1.end());
	sort(saher2.begin(),saher2.end());
	ll k=0;
	vl barla;
	REP(i,sz(U))barla.pb(0);
	ll g=ask(barla);
	REP(i,sz(saher1))
	{
		if (k!=saher1[i].f)
		{
			k++;
			if (g!=ask(barla))
			{
				k--;
				g=ask(barla);
				for (ll j=i-1;j>=0;j--)
				{
					barla[saher1[i].s]=0;
					if (g!=ask(barla))
					{
						res1=saher1[i].f;
						break;
					}
				}
				break;
			}
		}
		barla[saher1[i].s]=1;
	}
	REP(i,sz(saher2))
	{
		if (k!=saher2[i].f)
		{
			k++;
			if (g!=ask(barla))
			{
				k--;
				g=ask(barla);
				for (ll j=i-1;j>=0;j--)
				{
					barla[saher2[i].s]=0;
					if (g!=ask(barla))
					{
						res2=saher2[i].f;
						break;
					}
				}
				break;
			}
		}
		barla[saher1[i].s]=1;
	}
}
void bfs()
{
	bool b=0;
	REP(i,sz(saher1))
	{
		REP(j,sz(roads[saher1[i].s]))
		{
			if (!vis[nodes[saher1[i].s][j].f])
			{
				vis[nodes[saher1[i].s][j].f]=1;
				saher1.pb({san1,nodes[saher1[i].s][j].s});
			}
		}
	}
	san1++;
	REP(i,sz(saher2))
	{
		REP(j,sz(nodes[saher2[i].s]))
		{
			if (!vis[nodes[saher2[i].s][j].f])
			{
				vis[nodes[saher2[i].s][j].f]=1;
				saher2.pb({san2,nodes[saher2[i].s][j].s});
			}
		}
	}
	san2++;
	if (b)bfs();
	else find();
}
void binary_search()
{
	ll k=sz(U); k/=2;
	vl barla;
	REP(i,sz(U))barla.pb(0);
	ll h=ask(barla);
	barla[k]=1;
	while(h==ask(barla))
	{
		barla[k]=0;
		k/=2;
		barla[k]=1;
	}
	vis[roads[k].f]=1;
	vis[roads[k].s]=1;
	saher1.pb({0,roads[k].f});
	saher2.pb({0,roads[k].s});
	bfs();
}
void find_pair(ll N, vector<ll> U, vector<ll> V, ll A, ll B)
{
	REP(i,sz(U))
	{
		roads[i].pb({U[i],V[i]});
		nodes[U[i]].pb({V[i],i});
		nodes[V[i]].pb({U[i],i});
	}
	binary_search();
	answer(res1,res2);
}

Compilation message (stderr)

highway.cpp: In function 'void find()':
highway.cpp:42:7: error: 'ask' was not declared in this scope
   42 |  ll g=ask(barla);
      |       ^~~
highway.cpp: In function 'void binary_search()':
highway.cpp:125:7: error: 'ask' was not declared in this scope
  125 |  ll h=ask(barla);
      |       ^~~
highway.cpp:3:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'first'
    3 | #define f first
      |           ^~~~~
highway.cpp:133:15: note: in expansion of macro 'f'
  133 |  vis[roads[k].f]=1;
      |               ^
highway.cpp:4:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
    4 | #define s second
      |           ^~~~~~
highway.cpp:134:15: note: in expansion of macro 's'
  134 |  vis[roads[k].s]=1;
      |               ^
highway.cpp:3:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'first'
    3 | #define f first
      |           ^~~~~
highway.cpp:135:24: note: in expansion of macro 'f'
  135 |  saher1.pb({0,roads[k].f});
      |                        ^
highway.cpp:135:26: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
  135 |  saher1.pb({0,roads[k].f});
      |                          ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from highway.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
highway.cpp:4:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
    4 | #define s second
      |           ^~~~~~
highway.cpp:136:24: note: in expansion of macro 's'
  136 |  saher2.pb({0,roads[k].s});
      |                        ^
highway.cpp:136:26: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
  136 |  saher2.pb({0,roads[k].s});
      |                          ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from highway.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
highway.cpp: In function 'void find_pair(ll, std::vector<long long int>, std::vector<long long int>, ll, ll)':
highway.cpp:148:2: error: 'answer' was not declared in this scope
  148 |  answer(res1,res2);
      |  ^~~~~~