Submission #1343626

#TimeUsernameProblemLanguageResultExecution timeMemory
1343626limitsConnecting Supertrees (IOI20_supertrees)C++20
0 / 100
0 ms344 KiB
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define f0r(i, n) for (auto i = 0; i < (n); ++i)
#define fnr(i, n, k) for (auto i = (n); i < (k); ++i)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define F first
#define S second
#define ctn(x) cout << x << '\n'
#define forl(a, l) for (auto a : l)
#define ctl(l) for (auto &a : (l)) cout << a << ' '; cout << endl;
#define lb(v, x) (lower_bound(all(v), x) - begin(v))
#define ub(v, x) (upper_bound(all(v), x) - begin(v))
#define pq priority_queue

template <class T>
using V = vector<T>;
using ll = long long;
using vi = V<int>;
using vl = V<ll>;
using pi = pair<int, int>;
using ti = tuple<int, int, int>;
using Adj = V<vi>;
using vvi = V<vi>;

#include "supertrees.h"

int construct(V<vi> p) {
	int n = p.size();
	V<vi> ans(n, vi(n));

	V<bool> vis(n);
	V<vi> comps;
	f0r(i, n) if (!vis[i]) {
		comps.pb({});
		f0r(j, n) if (p[i][j]) comps.back().pb(j);
	}

	forl(&c, comps) {
		forl(u, c) forl(v, c) if (!p[u][v]) return 0;
		int u = c[0];
		if (c.size() == 2) return 0;
		c.pb(u);
		f0r(i, c.size()-1) ans[c[i]][c[i+1]] = ans[c[i+1]][c[i]] = 1;
		//fnr(i, 1, c.size()) ans[u][c[i]] = ans[c[i]][u] = 1;
	}

	build(ans);
	return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...