제출 #293835

#제출 시각아이디문제언어결과실행 시간메모리
293835Trickster통행료 (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#include <algorithm> #include <highway.h> #include <string.h> #include <iostream> #include <stdio.h> #include <vector> #include <queue> #include <cmath> #include <set> #include <map> using namespace std; #define maxN 200010 #define ff first #define ss second #define ll long long #define pb push_back #define mod 1000000007 #define pii pair <ll, ll> // #pragma GCC target ("avx2") // #pragma GCC optimization ("O3") // #pragma GCC optimization ("unroll-loops") ll bigmod(ll a,ll e) {if(e==0)return 1;ll x=bigmod(a*a%mod,e>>1);return e&1?x*a%mod:x;} pii L[maxN]; int n, m, dis; vector <pii> E[maxN]; int tap(vector <pii> v) { int l = 0, r = v.size()-1, md, in = 0; while(l <= r) { md = (l+r)/2; vector <int> arr; for(int i = 0; i < m; i++) arr.pb(0); for(int i = 0; i < v.size(); i++) for(auto h: E[v[i].ss]) arr[h.ss] = (i <= md ? 1 : 0); int cur = ask(arr); if(dis != cur) r = md-1, in = md; else l = md+1; } return v[in].ss; } void find_pair(int N, vector <int> U, vector <int> V, int A, int B) { m = U.size(), n = N; for(int i = 0; i < m; i++) { E[U[i]].pb({V[i], i}); E[V[i]].pb({U[i], i}); } vector <int> arr; for(int i = 0; i < m; i++) arr.pb(0); dis = ask(arr); int l = 0, r = m-1, md, in = 0; while(l <= r) { md = (l+r)/2; vector <int> arr; for(int i = 0; i < m; i++) arr.pb((i <= md ? 1 : 0)); int cur = ask(arr); if(dis != cur) r = md-1, in = md; else l = md+1; } queue <pii> Q; Q.push({U[in], 1}); Q.push({V[in], 2}); L[U[in]] = {0, 1}; L[V[in]] = {0, 2}; while(!Q.empty()) { int nd = Q.front().ff; int tp = Q.front().ss; Q.pop(); for(auto i: E[nd]) { if(L[i].ss) continue; L[i] = {L[nd].ff+1, tp}; Q.push({i, tp}); } } vector <pii> v; for(int i = 0; i < n; i++) if(L[i].ss == 1) v.pb({L[i].ff, i}); sort(v.begin(), v.end()); int s = tap(v); v.clear(); for(int i = 0; i < n; i++) if(L[i].ss == 2) v.pb({L[i].ff, i}); sort(v.begin(), v.end()); int t = tap(v); answer(s, t); }

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

highway.cpp: In function 'int tap(std::vector<std::pair<long long int, long long int> >)':
highway.cpp:39:26: 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]
   39 |         for(int i = 0; i < v.size(); i++)
      |                        ~~^~~~~~~~~~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:89:17: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int> [200010]' and 'std::pair<long long int, long long int>')
   89 |             if(L[i].ss) continue;
      |                 ^
highway.cpp:91:14: error: no match for 'operator[]' (operand types are 'std::pair<long long int, long long int> [200010]' and 'std::pair<long long int, long long int>')
   91 |             L[i] = {L[nd].ff+1, tp};
      |              ^
highway.cpp:92:27: error: no matching function for call to 'std::queue<std::pair<long long int, long long int> >::push(<brace-enclosed initializer list>)'
   92 |             Q.push({i, tp});
      |                           ^
In file included from /usr/include/c++/9/queue:64,
                 from highway.cpp:7:
/usr/include/c++/9/bits/stl_queue.h:259:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  259 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/9/bits/stl_queue.h:259:30: 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>&'}
  259 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_queue.h:264:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  264 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/9/bits/stl_queue.h:264:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  264 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~