제출 #334073

#제출 시각아이디문제언어결과실행 시간메모리
334073nicholask통행료 (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#include "highway.h" #include <bits/stdc++.h> #define x first #define y second using namespace std; vector <pair <int,int> > g[90000]; //first: connection to which node, second: edge no. int dist; vector <pair <int,int> > poss; void dfs(int cur,int prev,int 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){ int m=u.size(); for (int 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 (int i=0; i<m; i++){ if (u[i]!=i||v[i]!=i+1){ can=0; break; } } if (can){ //subtask 3 vector <int> possible; for (int i=0; i<n; i++) possible.push_back(i); while (possible.size()>1){ vector <int> f,s; for (int i=0; i<possible.size(); i++){ if (i<(possible.size()/2)) f.push_back(i); else s.push_back(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 <int> f,s; for (int i=0; i<possible.size(); i++){ if (i<(poss.size()/2)) f.push_back(i); else s.push_back(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); } }

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

highway.cpp: In function 'void dfs(int, int, int)':
highway.cpp:12:40: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&, int&)'
   12 |   if (d+1==dist) poss.push_back(i.y,i.x);
      |                                        ^
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<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:7: note:   candidate expects 1 argument, 2 provided
/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<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note:   candidate expects 1 argument, 2 provided
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    for (int i=0; i<possible.size(); i++){
      |                  ~^~~~~~~~~~~~~~~~
highway.cpp:37:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     if (i<(possible.size()/2)) f.push_back(i);
      |         ~^~~~~~~~~~~~~~~~~~~~
highway.cpp:50:20: error: 'possible' was not declared in this scope
   50 |    for (int i=0; i<possible.size(); i++){
      |                    ^~~~~~~~
highway.cpp:51:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     if (i<(poss.size()/2)) f.push_back(i);
      |         ~^~~~~~~~~~~~~~~~
highway.cpp:3:11: error: request for member 'first' in 'i', which is of non-class type 'int'
    3 | #define x first
      |           ^~~~~
highway.cpp:55:27: note: in expansion of macro 'x'
   55 |    for (auto&i:f) query[i.x]=1;
      |                           ^
highway.cpp:56:33: error: no match for 'operator=' (operand types are 'std::vector<std::pair<int, int> >' and 'std::vector<int>')
   56 |    if (ask(query)==a*dist) poss=s;
      |                                 ^
In file included from /usr/include/c++/9/vector:72,
                 from highway.h:3,
                 from highway.cpp:1:
/usr/include/c++/9/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<std::pair<int, int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
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:706:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:706:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::pair<int, int> >&&'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:727:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  727 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:727:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<std::pair<int, int> >'
  727 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
highway.cpp:57:14: error: no match for 'operator=' (operand types are 'std::vector<std::pair<int, int> >' and 'std::vector<int>')
   57 |    else poss=f;
      |              ^
In file included from /usr/include/c++/9/vector:72,
                 from highway.h:3,
                 from highway.cpp:1:
/usr/include/c++/9/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<std::pair<int, int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
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:706:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:706:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::pair<int, int> >&&'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:727:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  727 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:727:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<std::pair<int, int> >'
  727 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~