제출 #362985

#제출 시각아이디문제언어결과실행 시간메모리
362985vm152Traffic (IOI10_traffic)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std ; #define ios ios_base::sync_with_stdio(0); cin.tie(0) ; cout.tie(0) #define eb emplace_back #define mp make_pair #define f first #define s second #define endl '\n' typedef long long int ll ; const int MAX = 1e6 ; vector<ll> tree[MAX + 1] ; vector<ll> cnt[MAX + 1] ; ll sum = 0 ; bool compare(vector<ll>& a, vector<ll>& b) { if (a[1] < b[1]) return 1 ; if (a[1] == b[1]) { int i = 2, j = 2 ; while (i < (int)a.size() && j < (int)b.size() && a[i] == b[j]) i++ , j++ ; if (i >= (int)a.size()) return 1 ; if (j >= (int)b.size()) return 0 ; if (a[i] > b[j]) return 0 ; return 1 ; } return 0 ; } ll dfs(int node, int s, int p[]) { ll count = 0 ; for (int i : tree[node]) { if (i != s) { count = dfs(i, node, p) + p[i] ; cnt[node].eb(count) ; } } ll sm = 0 ; for (ll i : cnt[node]) sm += i ; cnt[node].eb(sum - sm - p[node]) ; return count ; } int LocateCentre(int n, int p[], int s[], int d[]) { sum = 0 ; for (int i = 0 ; i < n ; i++) sum += p[i] ; for (int i = 0; i < n - 1 ; i++) { tree[s[i]].eb(d[i]) ; tree[d[i]].eb(s[i]) ; } dfs(0, 0, p) ; vector<vector<int>> ans ; for (int i = 0 ; i < n ; i++) { if (!cnt[i].empty()) { sort(cnt[i].begin(), cnt[i].end()) ; reverse(cnt[i].begin(), cnt[i].end()) ; vector<int> temp ; temp.eb(i) ; for (ll j : cnt[i]) temp.eb(j) ; ans.eb(temp) ; } } sort(ans.begin(), ans.end(), compare) ; return ans[0][0] ; } /* int main(){ ios ; int n ; cin >> n ; int p[n] ; int s[n] ; int d[n] ; for (int i = 0 ; i < n ; i++) cin >> p[i] ; for (int i = 0 ; i < n - 1 ; i++) cin >> s[i] ; for (int i = 0 ; i < n - 1 ; i++) cin >> d[i] ; int ans = LocateCentre(n, p, s, d) ; cout << ans << endl ; } */

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

In file included from /usr/include/c++/9/bits/stl_algobase.h:71,
                 from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from traffic.cpp:1:
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = bool (*)(std::vector<long long int>&, std::vector<long long int>&)]':
/usr/include/c++/9/bits/stl_algo.h:81:17:   required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1920:34:   required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1952:38:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1967:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = bool (*)(std::vector<long long int>&, std::vector<long long int>&)]'
traffic.cpp:66:39:   required from here
/usr/include/c++/9/bits/predefined_ops.h:143:18: error: invalid initialization of reference of type 'std::vector<long long int>&' from expression of type 'std::vector<int>'
  143 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::vector<int>; _Iterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = bool (*)(std::vector<long long int>&, std::vector<long long int>&)]':
/usr/include/c++/9/bits/stl_algo.h:1827:20:   required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1854:36:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1884:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1970:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = bool (*)(std::vector<long long int>&, std::vector<long long int>&)]'
traffic.cpp:66:39:   required from here
/usr/include/c++/9/bits/predefined_ops.h:215:11: error: invalid initialization of reference of type 'std::vector<long long int>&' from expression of type 'std::vector<int>'
  215 |  { return bool(_M_comp(__val, *__it)); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Value = std::vector<int>; _Compare = bool (*)(std::vector<long long int>&, std::vector<long long int>&)]':
/usr/include/c++/9/bits/stl_heap.h:133:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Distance = long int; _Tp = std::vector<int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_heap.h:237:23:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Distance = long int; _Tp = std::vector<int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_heap.h:342:22:   required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1671:23:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1932:25:   required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1947:27:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:1967:25:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(std::vector<long long int>&, std::vector<long long int>&)>]'
/usr/include/c++/9/bits/stl_algo.h:4899:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Compare = bool (*)(std::vector<long long int>&, std::vector<long long int>&)]'
traffic.cpp:66:39:   required from here
/usr/include/c++/9/bits/predefined_ops.h:177:11: error: invalid initialization of reference of type 'std::vector<long long int>&' from expression of type 'std::vector<int>'
  177 |  { return bool(_M_comp(*__it, __val)); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~