Submission #136483

# Submission time Handle Problem Language Result Execution time Memory
136483 2019-07-25T11:07:27 Z Nucleist Highway Tolls (IOI18_highway) C++14
Compilation error
0 ms 0 KB
#include "highway.h"
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int dist[90001];
vector<int>adj[90001];
bool vis[90001];
map<pair<int,int>,int>gg;
map<pair<int,int>,int>gg1;
map<int,vector<int>>gg2;
int s,t;
int s1;
int n,m;
void dfs_tree(int node)
{
	dist[node]=s1;
	gg2[s1].pb(node);
	s1+=s;
	vis[node]=1;
	for (int i = 0; i < adj[node].size(); ++i)
	{
		if(vis[adj[node][i]]!=1)
			{	gg[{adj[node][i],node}]=gg1[{min(adj[node][i],node),max(adj[node][i],node)}];
				dfs_tree(adj[node][i]);}
	}
	s1-=s;
}
void find_pair(int N,vector<int>U, vector<int>V, int A, int B)
{
  //flash;
	n=N;
	m=U.size();
	for (int i = 0; i < m; ++i)
	{
		int x,y;
		x=U[i];
		y=V[i];
		adj[x].pb(y);
		adj[y].pb(x);
		gg1[{min(x,y),max(x,y)}]=i;
	}
	s=A;
	t=B;
	s1=0;
	dfs_tree(0);
	vector<int> now(m,0);
	ll vol = ask(now);
	vector<pair<int,int>>hi;
	for(auto it:gg2[vol])
	{
		auto voli = gg.lower_bound({it,-INF});
		auto kal = *voli;
		int kal1 = kal.second;
	}
	int l = 0;
	vector<int> hi = gg2[vol];
	int r = hi.size();
	while (l <= r) {
		fill(now.begin(), now.end(), 0);
        int m = (l+r)/2;
        int last=0;
        for (int i = l; i <= m; ++i)
        {
        	auto voli = gg.lower_bound({hi[i],-INF});
			auto kal = *voli;
			int kal1 = kal.second;
			now[kal1]=1;
			last=hi[i];
        }
        int dol = ask(now);
        if(l==r)
        {
        	answer(0,last);
        	return;
        }
        if(dol!=vol)r=m;
        else l=m+1;
    }
}
//code the AC sol !
// BS/queue/map

Compilation message

highway.cpp: In function 'void dfs_tree(int)':
highway.cpp:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < adj[node].size(); ++i)
                  ~~^~~~~~~~~~~~~~~~~~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:65:7: warning: unused variable 'kal1' [-Wunused-variable]
   int kal1 = kal.second;
       ^~~~
highway.cpp:68:14: error: conflicting declaration 'std::vector<int> hi'
  vector<int> hi = gg2[vol];
              ^~
highway.cpp:60:23: note: previous declaration as 'std::vector<std::pair<int, int> > hi'
  vector<pair<int,int>>hi;
                       ^~
highway.cpp:76:49: error: no matching function for call to 'std::map<std::pair<int, int>, int>::lower_bound(<brace-enclosed initializer list>)'
          auto voli = gg.lower_bound({hi[i],-INF});
                                                 ^
In file included from /usr/include/c++/7/map:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:81,
                 from highway.cpp:2:
/usr/include/c++/7/bits/stl_map.h:1233:7: note: candidate: std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]
       lower_bound(const key_type& __x)
       ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_map.h:1233:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_map.h:1239:2: note: candidate: template<class _Kt> decltype ((std::map<_Key, _Tp, _Compare, _Alloc>::iterator)(((std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::map<_Key, _Tp, _Compare, _Alloc>::lower_bound(const _Kt&) [with _Kt = _Kt; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]
  lower_bound(const _Kt& __x)
  ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_map.h:1239:2: note:   template argument deduction/substitution failed:
highway.cpp:76:49: note:   couldn't deduce template parameter '_Kt'
          auto voli = gg.lower_bound({hi[i],-INF});
                                                 ^
In file included from /usr/include/c++/7/map:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:81,
                 from highway.cpp:2:
/usr/include/c++/7/bits/stl_map.h:1258:7: note: candidate: std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator std::map<_Key, _Tp, _Compare, _Alloc>::lower_bound(const key_type&) const [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]
       lower_bound(const key_type& __x) const
       ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_map.h:1258:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_map.h:1264:2: note: candidate: template<class _Kt> decltype ((std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator)(((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::map<_Key, _Tp, _Compare, _Alloc>::lower_bound(const _Kt&) const [with _Kt = _Kt; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]
  lower_bound(const _Kt& __x) const
  ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_map.h:1264:2: note:   template argument deduction/substitution failed:
highway.cpp:76:49: note:   couldn't deduce template parameter '_Kt'
          auto voli = gg.lower_bound({hi[i],-INF});
                                                 ^
highway.cpp:80:13: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> > >::value_type {aka std::pair<int, int>}' to 'int' in assignment
    last=hi[i];
             ^