Submission #334079

#TimeUsernameProblemLanguageResultExecution timeMemory
334079nicholaskHighway Tolls (IOI18_highway)C++14
Compilation error
0 ms0 KiB
#include "highway.h" #include <bits/stdc++.h> #define x first #define y second #define ll long long using namespace std; vector <pair <ll,ll> > g[90000]; //first: connection to which node, second: edge no. ll dist; vector <pair <ll,ll> > poss; void dfs(ll cur,ll prev,ll d){ for (auto&i:g[cur]){ if (i.x==prev) continue; if (d+1==dist) poss.push_back({i.y,i.x}); else dfs(i.x,cur,d+1); } } void find_pair(int N,vector <int> U,vector <int> V,int A,int B){ ll n=N; ll m=u.size(); vector <ll> u; for (ll i=0; i<m; i++) u[i]=U[i]; vector <ll> v; for (ll i=0; i<m; i++) v[i]=V[i]; ll a=A; ll b=B; for (ll i=0; i<m; i++){ g[u[i]].push_back({v[i],i}); g[v[i]].push_back({u[i],i}); } vector <int> query(m,0); dist=ask(query)/a; bool can=1; for (ll i=0; i<m; i++){ if (u[i]!=i||v[i]!=i+1){ can=0; break; } } if (can){ //subtask 3 vector <ll> possible; for (ll i=0; i<n; i++) possible.push_back(i); while (possible.size()>1){ vector <ll> f,s; for (ll i=0; i<possible.size(); i++){ if (i<(possible.size()/2)) f.push_back(possible[i]); else s.push_back(possible[i]); } vector <int> query(m,0); for (auto&i:f) query[i]=1; if (ask(query)==a*dist) possible=s; else possible=f; } answer(possible[0],possible[0]+dist); } else { dfs(0,-1,0); while (poss.size()>1){ vector <pair <ll,ll> > f,s; for (int i=0; i<poss.size(); i++){ if (i<(poss.size()/2)) f.push_back(poss[i]); else s.push_back(poss[i]); } vector <int> query(m,0); for (auto&i:f) query[i.x]=1; if (ask(query)==a*dist) poss=s; else poss=f; } answer(0,poss[0].y); } }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:19:7: error: 'u' was not declared in this scope
   19 |  ll m=u.size();
      |       ^
highway.cpp:28:29: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
   28 |   g[v[i]].push_back({u[i],i});
      |                             ^
In file included from /usr/include/c++/9/vector:67,
                 from highway.h:3,
                 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:44:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |    for (ll i=0; i<possible.size(); i++){
      |                 ~^~~~~~~~~~~~~~~~
highway.cpp:45:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     if (i<(possible.size()/2)) f.push_back(possible[i]);
      |         ~^~~~~~~~~~~~~~~~~~~~
highway.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |    for (int i=0; i<poss.size(); i++){
      |                  ~^~~~~~~~~~~~
highway.cpp:59:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     if (i<(poss.size()/2)) f.push_back(poss[i]);
      |         ~^~~~~~~~~~~~~~~~
highway.cpp:25:5: warning: unused variable 'b' [-Wunused-variable]
   25 |  ll b=B;
      |     ^