제출 #305784

#제출 시각아이디문제언어결과실행 시간메모리
305784tincan슈퍼트리 잇기 (IOI20_supertrees)C++17
컴파일 에러
0 ms0 KiB
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<deque>
#include<string>
#include<unordered_map>
#include<bitset>
#include<random>
#include<chrono>
#define make(i, i2) {ans[i][i2] = ans[i2][i] = 1;}
//Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
using namespace std;
const int MAXN = 1005;
struct dsu {
	int arr[MAXN];
	int find(int s) { return arr[s] == s ? s : arr[s] = find(arr[s]); }
	void join(int a, int b) { if (find(a) != find(b)) arr[find(a)] = find(b); }
} st, st2;
vector<int> thng[MAXN];
int construct(vector<vector<int>> p) {
	int N = p.size();
	for (int i = 0; i < N; i++) for (int i2 = 0; i2 < N; i2++) if (p[i][i2] == 3) return 0;
	vector<vector<int>> ans;
	for (int i = 0; i < N; i++) {
		ans.push_back(vector<int>(N));
		for (int i2 = 0; i2 < N; i2++) ans[i][i2] = 0;
	}
	for (int i = 0; i < N; i++) {
		for (int i2 = i+1; i2 < N; i2++) {
			if (p[i][i2]) {
				if(p[i][i2] == 1) st2.join(i, i2);
				st.join(i, i2);
			}
			else if (!p[i][i2] && st.find(i) == st.find(i2)) return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		if (thng[st2.find(i)].size()) make(thng[st2.find(i)].back, i);
		thng[st2.find(i)].push_back(i);
	}
	for (int i = 0; i < N; i++) {
		for (int i2 =i+1; i2 < N; i2++) {
			if (p[i][i2] == 2) make(st2.find(i), st2.find(i2));
		}
	}
	build(ans); return 1;
}

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:16:25: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '<unresolved overloaded function type>')
   16 | #define make(i, i2) {ans[i][i2] = ans[i2][i] = 1;}
      |                         ^
supertrees.cpp:44:33: note: in expansion of macro 'make'
   44 |   if (thng[st2.find(i)].size()) make(thng[st2.find(i)].back, i);
      |                                 ^~~~
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from supertrees.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:1040: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]'
 1040 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1040:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1040 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1058: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]'
 1058 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1058:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1058 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:16:42: 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 '<unresolved overloaded function type>')
   16 | #define make(i, i2) {ans[i][i2] = ans[i2][i] = 1;}
      |                                          ^
supertrees.cpp:44:33: note: in expansion of macro 'make'
   44 |   if (thng[st2.find(i)].size()) make(thng[st2.find(i)].back, i);
      |                                 ^~~~
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from supertrees.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:1040: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]'
 1040 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1040:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1040 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1058: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]'
 1058 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1058:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1058 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
supertrees.cpp:52:2: error: 'build' was not declared in this scope
   52 |  build(ans); return 1;
      |  ^~~~~