답안 #838042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
838042 2023-08-26T06:08:28 Z caganyanmaz 슈퍼트리 잇기 (IOI20_supertrees) C++17
21 / 100
162 ms 24012 KB
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
constexpr static int MXN = 1e3 + 5;
struct Node
{
	int head, tail, size, nxt;
	Node(int i) : head(i), tail(i), size(1), nxt(-1) {}
	Node() : Node(-1) {}
};
Node node[MXN];

void merge(int a, int b);
int construct(vector<vector<int>> p)
{
	int n = p.size();
	vector<vector<int>> answer(n, vector<int>(n));
	for (int i = 0; i < n; i++) 
		node[i] = Node(i);
	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			if (p[i][j] && node[i].head != node[j].head)
			{
				merge(node[i].head, node[j].head);
				answer[i][j] = answer[j][i] = 1;
			}
		}
	}
	for (int i = 0; i < n; i++)
		for (int j = i+1; j < n; j++)
			if (!p[i][j] && node[i].head == node[j].head)
				return 0;
	build(answer);
	return 1;
}
void merge(int a, int b)
{
	if (node[a].size < node[b].size) swap(a, b);
	node[a].size += node[b].size;
	node[node[a].tail].nxt = b;
	node[a].tail = node[b].tail;
	for (;b!=-1;b=node[b].nxt)
		node[b].head = a;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 147 ms 22048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 147 ms 22048 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 6 ms 1224 KB Output is correct
13 Correct 142 ms 23904 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 816 KB Output is correct
17 Correct 74 ms 14096 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 37 ms 6240 KB Output is correct
21 Correct 156 ms 24012 KB Output is correct
22 Correct 142 ms 23964 KB Output is correct
23 Correct 162 ms 24008 KB Output is correct
24 Correct 154 ms 23976 KB Output is correct
25 Correct 65 ms 14080 KB Output is correct
26 Correct 62 ms 14084 KB Output is correct
27 Correct 152 ms 23948 KB Output is correct
28 Correct 147 ms 23936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Incorrect 1 ms 216 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 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 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 147 ms 22048 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 6 ms 1224 KB Output is correct
13 Correct 142 ms 23904 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 816 KB Output is correct
17 Correct 74 ms 14096 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 37 ms 6240 KB Output is correct
21 Correct 156 ms 24012 KB Output is correct
22 Correct 142 ms 23964 KB Output is correct
23 Correct 162 ms 24008 KB Output is correct
24 Correct 154 ms 23976 KB Output is correct
25 Correct 65 ms 14080 KB Output is correct
26 Correct 62 ms 14084 KB Output is correct
27 Correct 152 ms 23948 KB Output is correct
28 Correct 147 ms 23936 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 316 KB Output is correct
32 Incorrect 1 ms 216 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 147 ms 22048 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 6 ms 1224 KB Output is correct
13 Correct 142 ms 23904 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 816 KB Output is correct
17 Correct 74 ms 14096 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 37 ms 6240 KB Output is correct
21 Correct 156 ms 24012 KB Output is correct
22 Correct 142 ms 23964 KB Output is correct
23 Correct 162 ms 24008 KB Output is correct
24 Correct 154 ms 23976 KB Output is correct
25 Correct 65 ms 14080 KB Output is correct
26 Correct 62 ms 14084 KB Output is correct
27 Correct 152 ms 23948 KB Output is correct
28 Correct 147 ms 23936 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 316 KB Output is correct
32 Incorrect 1 ms 216 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -