Submission #1291621

#TimeUsernameProblemLanguageResultExecution timeMemory
1291621lucaskojima슈퍼트리 잇기 (IOI20_supertrees)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
#include "supertrees.h"
#define sz(x) (int)size(x)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

struct dsu {
	vector<int> e;
	dsu(int n) : e(n, -1) {}

	int find(int v) { return e[v] < 0 ? v : e[v] = find(e[v]); }
	bool same(int a, int b) { return find(a) == find(b); }
	void une(int a, int b) {
		a = find(a), b = find(b);
		if (a == b) return;
		if (e[a] < e[b]) swap(a, b);
		e[b] += e[a];
		e[a] = b;
	}
};

int construct(vector<vector<int>> p) {
	in n = sz(p);

	dsu dsu(n);
	for (int i = 0; i < n; i++)
		for (int j = i; j < n; j++)
			if (p[i][j] == 1)
				dsu.une(i, j);

	for (int i = 0; i < n; i++)
		for (int j = i; j < n; j++)
			if (p[i][j] == 0 && dsu.same(i, j))
				return 0;

	vector<int> comp(n);
	for (int i = 0; i < n; i++) {
		int p = dsu.find(i);
		comp[p].push_back(i);
	}

	vector ans(n, vector<int>(n));
	for (int i = 0; i < n; i++)
		for (int x : comp[i]) {
			ans[i][x] = 1;
			ans[x][i] = 1;
		}

	build(ans);
	return 1;
}

Compilation message (stderr)

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:31:9: error: 'in' was not declared in this scope; did you mean 'yn'?
   31 |         in n = sz(p);
      |         ^~
      |         yn
supertrees.cpp:33:17: error: 'n' was not declared in this scope
   33 |         dsu dsu(n);
      |                 ^
supertrees.cpp:47:25: error: request for member 'push_back' in 'comp.std::vector<int>::operator[](((std::vector<int>::size_type)p))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   47 |                 comp[p].push_back(i);
      |                         ^~~~~~~~~
supertrees.cpp:52:36: error: 'begin' was not declared in this scope
   52 |                 for (int x : comp[i]) {
      |                                    ^
supertrees.cpp:52:36: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:166,
                 from supertrees.cpp:1:
/usr/include/c++/13/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/13/filesystem:50,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:200:
/usr/include/c++/13/bits/fs_dir.h:607:3: note:   'std::filesystem::__cxx11::begin'
  607 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
supertrees.cpp:52:36: error: 'end' was not declared in this scope
   52 |                 for (int x : comp[i]) {
      |                                    ^
supertrees.cpp:52:36: note: suggested alternatives:
/usr/include/c++/13/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/13/bits/fs_dir.h:612:3: note:   'std::filesystem::__cxx11::end'
  612 |   end(recursive_directory_iterator) noexcept
      |   ^~~