Submission #962549

#TimeUsernameProblemLanguageResultExecution timeMemory
962549tutis봉쇄 시간 (IOI23_closing)C++17
Compilation error
0 ms0 KiB
#include "closing.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W) { vector <pair<int, int>> adj[N]; vector <vector<int>> adj1[2]; adj1[0] = vector<int>(N); adj1[1] = vector<int>(N); for (int i = 0; i < N - 1; i++) { adj[U[i]].push_back({V[i], W[i]}); adj[V[i]].push_back({U[i], W[i]}); } vector <ll> D[2]; D[0] = vector<ll>(N); D[1] = vector<ll>(N); int XY[2] = {X, Y}; vector<int> x2y; for (int t: {0, 1}) { D[t][XY[t]] = 0; vector<int> P; function<void(int, int)> dfs = [&](int i, int p) -> void { if (p != -1) { adj1[t][p].push_back(i); } P.push_back(i); if (t == 0 && i == Y) { x2y = P; } for (auto j: adj[i]) { if (j.first == p) { continue; } D[t][j.first] = D[t][i] + j.second; dfs(j.first, i); } P.pop_back(); }; dfs(XY[t], -1); } int ret = 0; vector <ll> cost[2]; for (int t: {0, 1}) { ll sum = 0; priority_queue <pair<int, int>> Q; Q.push({0, XY[t]}); while (!Q.empty()) { int i = Q.top().second; sum += D[t][i]; cost[t].push_back(sum); if (sum > K) { break; } for (auto j: adj1[t][i]) { Q.push({-D[t][j], j}); } } } for (int i = 0; i < cost[0].size(); i++) { for (int j = 0; j < cost[1].size(); j++) { if (cost[0][i] + cost[1][j] <= K) { ret = max(ret, i + 1 + j + 1); } } } int m = 0; while (m + 1 < x2y.size() && D[0][x2y[m + 1]] <= D[1][x2y[m + 1]]) { m++; } ll s0 = 0; ll s1 = 0; for (int i = 0; i <= m; i++) { s0 += D[0][x2y[i]]; s0 = min(s, K + 1); } for (int j = x2y.size() - 1; j > m; j--) { s1 += D[1][x2y[j]]; s1 = min(s, K + 1); } if (s0 + s1 > K) { return ret; } return ret; }

Compilation message (stderr)

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:13:28: error: no match for 'operator=' (operand types are 'std::vector<std::vector<int> >' and 'std::vector<int>')
   13 |     adj1[0] = vector<int>(N);
      |                            ^
In file included from /usr/include/c++/10/vector:72,
                 from closing.h:1,
                 from closing.cpp:1:
/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 = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<std::vector<int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from closing.h:1,
                 from closing.cpp:1:
/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 = std::vector<int>; _Alloc = std::allocator<std::vector<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 'std::vector<int>' to 'std::vector<std::vector<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 = std::vector<int>; _Alloc = std::allocator<std::vector<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 'std::vector<int>' to 'std::initializer_list<std::vector<int> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
closing.cpp:14:28: error: no match for 'operator=' (operand types are 'std::vector<std::vector<int> >' and 'std::vector<int>')
   14 |     adj1[1] = vector<int>(N);
      |                            ^
In file included from /usr/include/c++/10/vector:72,
                 from closing.h:1,
                 from closing.cpp:1:
/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 = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<std::vector<int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from closing.h:1,
                 from closing.cpp:1:
/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 = std::vector<int>; _Alloc = std::allocator<std::vector<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 'std::vector<int>' to 'std::vector<std::vector<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 = std::vector<int>; _Alloc = std::allocator<std::vector<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 'std::vector<int>' to 'std::initializer_list<std::vector<int> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
closing.cpp:64:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for (int i = 0; i < cost[0].size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~
closing.cpp:65:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for (int j = 0; j < cost[1].size(); j++) {
      |                         ~~^~~~~~~~~~~~~~~~
closing.cpp:73:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     while (m + 1 < x2y.size() && D[0][x2y[m + 1]] <= D[1][x2y[m + 1]]) {
      |            ~~~~~~^~~~~~~~~~~~
closing.cpp:80:18: error: 's' was not declared in this scope
   80 |         s0 = min(s, K + 1);
      |                  ^
closing.cpp:84:18: error: 's' was not declared in this scope
   84 |         s1 = min(s, K + 1);
      |                  ^