답안 #441923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441923 2021-07-06T14:46:04 Z PiejanVDC 슈퍼트리 잇기 (IOI20_supertrees) C++17
컴파일 오류
0 ms 0 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;

int construct(vector<vector<int>> p) {
    int n = p.size();
    vector<vector<int>>v(n,vector<int>(n,0));
    for(int i = 0 ; i < n-1 ; i++) {
        for(int j = i+1 ; j < n ; j++) {
            if(p[i][j]) {
                bool ok=true;
                stack<pair<int,int>>s;
                s.push({i,-1});
                while(!s.empty()) {
                    if(s.top().first == j)
                        ok=false; break;
                    for(int k = 0 ; k < n ; k++) {
                        if(k==s.top().first||k==s.top().second) continue;
                        if(v[s.top()][k]) {
                            s.push(k);
                        }
                    }
                }
                if(ok) {
                    v[i][j]=1,v[j][i]=1;
                }
            }
        }
    }
    for(int i = 0 ; i < n ; i++) {
        for(int j = i+1 ; j < n ; j++) {
            if(!p[i][j]) {
                bool ok=true;
                stack<pair<int,int>>s;
                s.push({i,-1});
                while(!s.empty()) {
                    if(s.top().first == j)
                        ok=false; break;
                    for(int k = 0 ; k < n ; k++) {
                        if(k==s.top().first||k==s.top().second) continue;
                        if(v[s.top()][k]) {
                            s.push(k);
                        }
                    }
                }
                if(!ok) {
                    return 0;
                }
            }
        }
    }
    build(v);
    return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:15:21: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   15 |                     if(s.top().first == j)
      |                     ^~
supertrees.cpp:16:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |                         ok=false; break;
      |                                   ^~~~~
supertrees.cpp:19:29: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   19 |                         if(v[s.top()][k]) {
      |                             ^
In file included from /usr/include/c++/10/vector:67,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::const_reference = const std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:20:37: error: no matching function for call to 'std::stack<std::pair<int, int> >::push(int&)'
   20 |                             s.push(k);
      |                                     ^
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from supertrees.cpp:2:
/usr/include/c++/10/bits/stl_stack.h:239:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::stack<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  239 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_stack.h:239:30: note:   no known conversion for argument 1 from 'int' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  239 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_stack.h:244:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(std::stack<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::stack<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  244 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_stack.h:244:25: note:   no known conversion for argument 1 from 'int' to 'std::stack<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  244 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
supertrees.cpp:37:21: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   37 |                     if(s.top().first == j)
      |                     ^~
supertrees.cpp:38:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   38 |                         ok=false; break;
      |                                   ^~~~~
supertrees.cpp:41:29: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   41 |                         if(v[s.top()][k]) {
      |                             ^
In file included from /usr/include/c++/10/vector:67,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::const_reference = const std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:42:37: error: no matching function for call to 'std::stack<std::pair<int, int> >::push(int&)'
   42 |                             s.push(k);
      |                                     ^
In file included from /usr/include/c++/10/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:89,
                 from supertrees.cpp:2:
/usr/include/c++/10/bits/stl_stack.h:239:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::stack<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  239 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_stack.h:239:30: note:   no known conversion for argument 1 from 'int' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  239 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_stack.h:244:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(std::stack<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >; std::stack<_Tp, _Sequence>::value_type = std::pair<int, int>]'
  244 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_stack.h:244:25: note:   no known conversion for argument 1 from 'int' to 'std::stack<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
  244 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~