제출 #423167

#제출 시각아이디문제언어결과실행 시간메모리
423167JUANDI321슈퍼트리 잇기 (IOI20_supertrees)C++17
컴파일 에러
0 ms0 KiB
#include "supertrees.h"
#include <vector>
#include <deque>
 
using namespace std;
bool ch[1010];
 
int construct(vector<vector<int>> p) {
	int n = p.size();
	vector<vector<int>> answer;
	for (int i = 0; i < n; i++) 
	{
		vector<int> row;
		row.resize(n);
		answer.push_back(row);
	}
	for(int i = 0; i<n; i++)
	{
		for(int j = i+1; j<n; j++)
		{
			if(p[i][j] == 0)
			{
				for(int h = 0; h < n; h++)
				{
					if(p[i][h] == 1 && p[j][h] == 1)return 0;
				}
			}
		}
	}
	deque<int> l;
	for(int i = 0; i<n; i++)
	{
		if(!ch[i])
		{
			ch[i]=true;
			l.clear();
			l.push_back(i);
			int ant = i;
			for(int j = 0; j<n; j++)
			{
				if(p[i][j] == 1 && i != j)
				{
					ch[j]=true;
					answer[ant][j]=1;
					answer[j][ant]=1;
					ant = j;
					l.push_back(j);
				}
			}
			if(l.size()>2)
			{
				answer[l.front()][l.end()] = 1;
				answer[l.end()][l.front()] = 1;
			}
			else return 0;
		}
	}
	build(answer);
	return 1;
}

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:52:22: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'std::deque<int>::iterator' {aka 'std::_Deque_base<int, std::allocator<int> >::iterator'})
   52 |     answer[l.front()][l.end()] = 1;
      |                      ^
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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = 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 'std::deque<int>::iterator' {aka 'std::_Deque_base<int, std::allocator<int> >::iterator'} to '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 = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const 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 'std::deque<int>::iterator' {aka 'std::_Deque_base<int, std::allocator<int> >::iterator'} to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:53:11: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and 'std::deque<int>::iterator' {aka 'std::_Deque_base<int, std::allocator<int> >::iterator'})
   53 |     answer[l.end()][l.front()] = 1;
      |           ^
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 'std::deque<int>::iterator' {aka 'std::_Deque_base<int, std::allocator<int> >::iterator'} 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 'std::deque<int>::iterator' {aka 'std::_Deque_base<int, std::allocator<int> >::iterator'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~