Submission #471525

#TimeUsernameProblemLanguageResultExecution timeMemory
471525blueParachute rings (IOI12_rings)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> using namespace std; struct disjoint_set { int S; vector<short> parent; vector<short> subtree; disjoint_set() { ; } disjoint_set(int s) { S = s; parent = vector<int>(S); subtree = vector<int>(S); for(int i = 0; i < S; i++) { parent[i] = i; subtree[i] = 1; } } int root(int u) { int v = u; while(parent[v] != v) v = parent[v]; parent[u] = v; return v; } bool connected(int u, int v) { return root(u) == root(v); } void join(int u, int v) { u = root(u); v = root(v); if(u == v) return; if(subtree[u] < subtree[v]) swap(u, v); subtree[u] += subtree[v]; parent[v] = u; } }; const int X = 0; const int Y = 1; const int Z = 2; int state = Z; int N; vector<int> Z_critical; vector< vector<short> > Z_degree; vector<disjoint_set> DSU; vector<bool> good; void Init(int N_) { N = N_; for(int i = 0; i < N; i++) { Z_critical.push_back(i); Z_degree.push_back(vector<int>(N, 0)); DSU.push_back(disjoint_set(N)); good.push_back(1); } } void Link(int A, int B) { if(state == Z) { for(int q = 0; q < (int)Z_critical.size(); q++) { int z = Z_critical[q]; if(A == z || B == z) { continue; } if(DSU[q].connected(A, B)) { good[q] = 0; } Z_degree[q][A]++; Z_degree[q][B]++; if(Z_degree[q][A] > 2 || Z_degree[q][B] > 2) good[q] = 0; DSU[q].join(A, B); } } } int CountCritical() { int res = 0; for(int i = 0; i < N; i++) { res += good[i]; } return res; }

Compilation message (stderr)

rings.cpp: In constructor 'disjoint_set::disjoint_set(int)':
rings.cpp:19:31: error: no match for 'operator=' (operand types are 'std::vector<short int>' and 'std::vector<int>')
   19 |         parent = vector<int>(S);
      |                               ^
In file included from /usr/include/c++/10/vector:72,
                 from rings.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 = short int; _Alloc = std::allocator<short 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<short int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from rings.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 = short int; _Alloc = std::allocator<short 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<short 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 = short int; _Alloc = std::allocator<short 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<short int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
rings.cpp:20:32: error: no match for 'operator=' (operand types are 'std::vector<short int>' and 'std::vector<int>')
   20 |         subtree = vector<int>(S);
      |                                ^
In file included from /usr/include/c++/10/vector:72,
                 from rings.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 = short int; _Alloc = std::allocator<short 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<short int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from rings.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 = short int; _Alloc = std::allocator<short 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<short 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 = short int; _Alloc = std::allocator<short 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<short int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
rings.cpp: In function 'void Init(int)':
rings.cpp:72:45: error: no matching function for call to 'std::vector<std::vector<short int> >::push_back(std::vector<int>)'
   72 |         Z_degree.push_back(vector<int>(N, 0));
      |                                             ^
In file included from /usr/include/c++/10/vector:67,
                 from rings.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<short int>; _Alloc = std::allocator<std::vector<short int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<short int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const value_type&' {aka 'const std::vector<short int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<short int>; _Alloc = std::allocator<std::vector<short int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<short int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<std::vector<short int> >::value_type&&' {aka 'std::vector<short int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~