답안 #1034169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1034169 2024-07-25T10:18:24 Z Gray 슈퍼트리 잇기 (IOI20_supertrees) C++17
21 / 100
138 ms 24144 KB
#include "supertrees.h"
#include <vector>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define ln "\n"
#define pll pair<ll, ll>

struct DSU{
	vector<ll> p;
	ll n;
	DSU(ll N){
		n=N;
		p.resize(n, -1);
	}
	ll get(ll x){
		return p[x]==-1?x:p[x]=get(p[x]);
	}
	bool unite(ll a, ll b){
		a=get(a);
		b=get(b);
		if (a==b) return 0;
		p[a]=b;
		return 1;
	}
};

int construct(std::vector<std::vector<int>> p) {
	ll n = (ll)p.size();
	bool pos=1;
	DSU tr(n);
	vector<vector<int>> ans(n, vector<int>(n, 0));
	for (ll i=0; i<n; i++){
		for (ll j=0; j<n; j++){
			if (i==j) continue;
			if (p[i][j]){
				if (tr.unite(i, j)) {ans[i][j]=1; ans[j][i]=1;}
			}
		}
	}
	for (ll i=0; i<n; i++){
		for (ll j=0; j<n; j++){
			if (tr.get(i)==tr.get(j) and i!=j and p[i][j]==0){
				pos=0;
			}
		}
	}
	if (!pos) return 0;
	build(ans);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 10 ms 1372 KB Output is correct
7 Correct 122 ms 24144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 10 ms 1372 KB Output is correct
7 Correct 122 ms 24144 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1336 KB Output is correct
13 Correct 113 ms 24044 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 952 KB Output is correct
17 Correct 76 ms 14192 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 33 ms 6180 KB Output is correct
21 Correct 138 ms 24040 KB Output is correct
22 Correct 135 ms 24060 KB Output is correct
23 Correct 119 ms 23892 KB Output is correct
24 Correct 114 ms 23892 KB Output is correct
25 Correct 56 ms 14164 KB Output is correct
26 Correct 53 ms 14188 KB Output is correct
27 Correct 124 ms 24056 KB Output is correct
28 Correct 114 ms 23920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 10 ms 1372 KB Output is correct
7 Correct 122 ms 24144 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1336 KB Output is correct
13 Correct 113 ms 24044 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 952 KB Output is correct
17 Correct 76 ms 14192 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 33 ms 6180 KB Output is correct
21 Correct 138 ms 24040 KB Output is correct
22 Correct 135 ms 24060 KB Output is correct
23 Correct 119 ms 23892 KB Output is correct
24 Correct 114 ms 23892 KB Output is correct
25 Correct 56 ms 14164 KB Output is correct
26 Correct 53 ms 14188 KB Output is correct
27 Correct 124 ms 24056 KB Output is correct
28 Correct 114 ms 23920 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 10 ms 1372 KB Output is correct
7 Correct 122 ms 24144 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 5 ms 1336 KB Output is correct
13 Correct 113 ms 24044 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 952 KB Output is correct
17 Correct 76 ms 14192 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 33 ms 6180 KB Output is correct
21 Correct 138 ms 24040 KB Output is correct
22 Correct 135 ms 24060 KB Output is correct
23 Correct 119 ms 23892 KB Output is correct
24 Correct 114 ms 23892 KB Output is correct
25 Correct 56 ms 14164 KB Output is correct
26 Correct 53 ms 14188 KB Output is correct
27 Correct 124 ms 24056 KB Output is correct
28 Correct 114 ms 23920 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -