제출 #1301139

#제출 시각아이디문제언어결과실행 시간메모리
1301139sano슈퍼트리 잇기 (IOI20_supertrees)C++20
컴파일 에러
0 ms0 KiB
// Source: https://usaco.guide/general/io #include <iostream> // cin, cout #include <vector> // vector #include <string> // string #include <set> #include "supertrees.h" #define vec vector #define mod 1000000007 #define For(i,n) for(int i = 0; i < n; i++) using namespace std; int komponenty(vec<vec<int>>&p, vec<vec<int>>&comp, vec<int>&t){ int n = p.size(); vec<int> kde(n, -1); for(auto i : t){ int zakl = 0; if(kde[i] == -1){ vec<int> s; s.push_back(i); comp.push_back(s); kde[i] = comp.size() - 1; zakl = 1; } int poc = 0; For(j, n){ if(p[i][j] == 0) continue; poc++; if(kde[j] == -1){ if(zakl){ kde[j] = kde[i]; comp[kde[i]].push_back(j); } else{ return 0; } } if(kde[j] != kde[i]){ return 0; } } if(poc != comp[kde[i]].size()) return 0; } } int construct(vec<vec<int>>p){ int n = p.size(); vec<vec<int>> odp(n, vec<int>(n)); vec<vec<int>> comp; vec<int> t; For(i, n){ t.push_back(i); } int da_sa = komponenty(p, comp, t); For(i, n){ For(j, n){ if(p[i][j] == 2) p[i][j] = 0; } } For(i, comp.size()){ if(comp[i].size() == 1) continue; vec<vec<int>> comp2; da_sa = komponenty(p, comp2, comp[i]); For(j, comp2.size()){ For(k, comp2[j].size()-1){ odp[comp2[k]][comp2[k+1]] = 1; odp[comp2[k+1]][comp2[k]] = 1; } int p1 = comp2[j][0]; int p2 = comp2[(j+1)%(comp2.size())][0]; odp[p1][p2] = 1; odp[p2][p1] = 1; } } build(odp); return 1; } /* int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); return 0; }*/

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:66:20: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   66 |                 odp[comp2[k]][comp2[k+1]] = 1;
      |                    ^
In file included from /usr/include/c++/13/vector:66,
                 from supertrees.cpp:3:
/usr/include/c++/13/bits/stl_vector.h:1126:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; reference = std::vector<int>&; size_type = long unsigned int]'
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1126:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1145:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; const_reference = const std::vector<int>&; size_type = long unsigned int]'
 1145 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1145:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1145 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:67:20: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   67 |                 odp[comp2[k+1]][comp2[k]] = 1;
      |                    ^
/usr/include/c++/13/bits/stl_vector.h:1126:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; reference = std::vector<int>&; size_type = long unsigned int]'
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1126:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1126 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1145:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; const_reference = const std::vector<int>&; size_type = long unsigned int]'
 1145 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1145:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1145 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp: In function 'int komponenty(std::vector<std::vector<int> >&, std::vector<std::vector<int> >&, std::vector<int>&)':
supertrees.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^