제출 #293460

#제출 시각아이디문제언어결과실행 시간메모리
293460Muhammetali통행료 (IOI18_highway)C++11
컴파일 에러
0 ms0 KiB
#include "highway.h" #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; 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,count; vpl 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].f]>gos+ab[v[par[k].s]]) { jem[par[k].f]=gos+ab[v[par[k].s]]; dfs(par[k].f,gos+ab[v[par[k].s]]); } } } void sum(ll toll) { dfs(1); REP(i,sz(count)) { if (count[i]==1)continue; if (jem[count[i]]!=toll)count.erase(i,1); } } void recur(int M,int sum=0) { if (sum==M) { sum(ask(v)); return; } FOR(i,0,1) { w.pb(i); recur(M,sum+1); w.pop_back(); } } void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { int M = U.size(); ab.pb(A); ab.pb(B); bool bo[N]={0}; REP(i,sz(U)) { if (bo[U[i]]==0) { bo[U[i]]=1; count.pb(U[i]); } if (bo[V[i]]==0) { bo[V[i]]=1; count.pb(V[i]); } par[U[i]].pb(V[i],i); par[V[i]].pb(U[i],i); } recur(M); answer(count[0],count[1]); }

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

highway.cpp: In function 'void dfs(ll, ll)':
highway.cpp:4:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'first'
    4 | #define f first
      |           ^~~~~
highway.cpp:40:18: note: in expansion of macro 'f'
   40 |   if (jem[par[k].f]>gos+ab[v[par[k].s]])
      |                  ^
highway.cpp:5:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
    5 | #define s second
      |           ^~~~~~
highway.cpp:40:37: note: in expansion of macro 's'
   40 |   if (jem[par[k].f]>gos+ab[v[par[k].s]])
      |                                     ^
highway.cpp:4:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'first'
    4 | #define f first
      |           ^~~~~
highway.cpp:42:15: note: in expansion of macro 'f'
   42 |    jem[par[k].f]=gos+ab[v[par[k].s]];
      |               ^
highway.cpp:5:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
    5 | #define s second
      |           ^~~~~~
highway.cpp:42:34: note: in expansion of macro 's'
   42 |    jem[par[k].f]=gos+ab[v[par[k].s]];
      |                                  ^
highway.cpp:4:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'first'
    4 | #define f first
      |           ^~~~~
highway.cpp:43:15: note: in expansion of macro 'f'
   43 |    dfs(par[k].f,gos+ab[v[par[k].s]]);
      |               ^
highway.cpp:5:11: error: 'vpl' {aka 'class std::vector<std::pair<long long int, long long int> >'} has no member named 'second'
    5 | #define s second
      |           ^~~~~~
highway.cpp:43:33: note: in expansion of macro 's'
   43 |    dfs(par[k].f,gos+ab[v[par[k].s]]);
      |                                 ^
highway.cpp: In function 'void sum(ll)':
highway.cpp:50:11: error: reference to 'count' is ambiguous
   50 |  REP(i,sz(count))
      |           ^~~~~
highway.cpp:16:39: note: in definition of macro 'REP'
   16 | #define REP(i,a) for (int i = 0; i < (a); ++i)
      |                                       ^
highway.cpp:50:8: note: in expansion of macro 'sz'
   50 |  REP(i,sz(count))
      |        ^~
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4107:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4107 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
highway.cpp:33:9: note:                 'vl count'
   33 | vl v,ab,count;
      |         ^~~~~
highway.cpp:52:7: error: reference to 'count' is ambiguous
   52 |   if (count[i]==1)continue;
      |       ^~~~~
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4107:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4107 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
highway.cpp:33:9: note:                 'vl count'
   33 | vl v,ab,count;
      |         ^~~~~
highway.cpp:53:11: error: reference to 'count' is ambiguous
   53 |   if (jem[count[i]]!=toll)count.erase(i,1);
      |           ^~~~~
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4107:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4107 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
highway.cpp:33:9: note:                 'vl count'
   33 | vl v,ab,count;
      |         ^~~~~
highway.cpp:53:27: error: reference to 'count' is ambiguous
   53 |   if (jem[count[i]]!=toll)count.erase(i,1);
      |                           ^~~~~
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4107:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4107 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
highway.cpp:33:9: note:                 'vl count'
   33 | vl v,ab,count;
      |         ^~~~~
highway.cpp: In function 'void recur(int, int)':
highway.cpp:60:11: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'vl' {aka 'std::vector<long long int>'}
   60 |   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:60:13: error: 'sum' cannot be used as a function
   60 |   sum(ask(v));
      |             ^
highway.cpp:65:3: error: 'w' was not declared in this scope
   65 |   w.pb(i);
      |   ^
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:80:4: error: reference to 'count' is ambiguous
   80 |    count.pb(U[i]);
      |    ^~~~~
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4107:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4107 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
highway.cpp:33:9: note:                 'vl count'
   33 | vl v,ab,count;
      |         ^~~~~
highway.cpp:85:4: error: reference to 'count' is ambiguous
   85 |    count.pb(V[i]);
      |    ^~~~~
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4107:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4107 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
highway.cpp:33:9: note:                 'vl count'
   33 | vl v,ab,count;
      |         ^~~~~
highway.cpp:87:22: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, int&)'
   87 |   par[U[i]].pb(V[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: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<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:7: note:   candidate expects 1 argument, 2 provided
highway.cpp:88:22: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, int&)'
   88 |   par[V[i]].pb(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: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<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:7: note:   candidate expects 1 argument, 2 provided
highway.cpp:91:9: error: reference to 'count' is ambiguous
   91 |  answer(count[0],count[1]);
      |         ^~~~~
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4107:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4107 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
highway.cpp:33:9: note:                 'vl count'
   33 | vl v,ab,count;
      |         ^~~~~
highway.cpp:91:18: error: reference to 'count' is ambiguous
   91 |  answer(count[0],count[1]);
      |                  ^~~~~
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from highway.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:4107:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits<_Iterator>::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4107 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
highway.cpp:33:9: note:                 'vl count'
   33 | vl v,ab,count;
      |         ^~~~~