Submission #1014235

#TimeUsernameProblemLanguageResultExecution timeMemory
1014235codexistentTraffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <traffic.h> using namespace std; #define MAXN 1000005 #define int long long #define FOR(i, a, b) for(int i = a; i <= b; i++) int t = 0, sum[MAXN], p[MAXN]; pair<int, int> r = make_pair(-1, 2000000005); vector<int> e[MAXN]; int dfs(int i = 0, int par = 0){ sum[i] = p[i]; int mx = 0; for(int i2 : e[i]) if(i != par){ sum[i] += dfs(i2, i); mx = max(mx, sum[i2]); } mx = max(mx, t - mx - p[i]); if(mx < r.second){ r.first = i; r.second = mx; } return sum[i]; } int LocateCentre(int N, int P[], int S[], int D[]){ if(N == 1) return 0; FOR(i, 0, n - 1) t += P[i], p[i] = P[i]; FOR(i, 0, n - 2) { e[S[i]] = D[i]; e[D[i]] = S[i]; } dfs(); return r.first; }

Compilation message (stderr)

traffic.cpp: In function 'long long int LocateCentre(long long int, long long int*, long long int*, long long int*)':
traffic.cpp:33:15: error: 'n' was not declared in this scope
   33 |     FOR(i, 0, n - 1) t += P[i], p[i] = P[i];
      |               ^
traffic.cpp:7:42: note: in definition of macro 'FOR'
    7 | #define FOR(i, a, b) for(int i = a; i <= b; i++)
      |                                          ^
traffic.cpp:34:15: error: 'n' was not declared in this scope
   34 |     FOR(i, 0, n - 2) {
      |               ^
traffic.cpp:7:42: note: in definition of macro 'FOR'
    7 | #define FOR(i, a, b) for(int i = a; i <= b; i++)
      |                                          ^
traffic.cpp:35:22: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'long long int')
   35 |         e[S[i]] = D[i];
      |                      ^
In file included from /usr/include/c++/10/vector:72,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'long long int' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
traffic.cpp:36:22: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'long long int')
   36 |         e[D[i]] = S[i];
      |                      ^
In file included from /usr/include/c++/10/vector:72,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'long long int' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~