답안 #1043709

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043709 2024-08-04T14:27:10 Z DeathIsAwe 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
120 ms 22280 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;

int construct(vector<vector<int>> p) {
	int n = p.size(), prev;
	vector<vector<int>> ans(n);
	bool visited[n];
	for (int i=0;i<n;i++) {
		visited[i] = false;
		for (int j=0;j<n;j++) {
			ans[i].push_back(0);
		}
	}
	vector<vector<int>> currentnodes(3);
	for (int i=0;i<n;i++) {
		if (visited[i]) {
			continue;
		}
		visited[i] = true;
		for (int j=0;j<3;j++) {
			currentnodes[j].clear();
		}
		for (int j=0;j<n;j++) {
			if (j == i) {
				continue;
			}
			if (p[i][j] > 0) {
				if (visited[j]) {
					return 0;
				}
				visited[j] = true;
				if (p[i][j] == 1) {
					currentnodes[1].push_back(j);
				} else if (p[i][j] == 2) {
					currentnodes[2].push_back(j);
				} else if (p[i][j] == 3) {
					return 0;
				}
			}
		}
		//for (int j: currentnodes[1]) {
		//	cout << j << ' ';
		//}
		//cout << '\n';
		//for (int j: currentnodes[2]) {
		//	cout << j << ' ';
		//}
		//cout << '\n';
		for (int j: currentnodes[1]) {
			for (int k=0;k<n;k++) {
				if (!visited[k]) {
					if (p[j][k] != 0) {
						return 0;
					}
				}
			}
		}
		for (int j: currentnodes[2]) {
			for (int k=0;k<n;k++) {
				if (!visited[k]) {
					if (p[j][k] != 0) {
						return 0;
					}
				}
			}
		}
		


		
		if (currentnodes[2].size() == 1) {
			return 0;
		}
		for (int j: currentnodes[1]) {
			for (int k: currentnodes[1]) {
				if (p[j][k] != 1) {
					return 0;
				}
			}
			for (int k: currentnodes[2]) {
				if (p[j][k] != 2) {
					return 0;
				}
			}
		}
        /*
		for (int j: currentnodes[2]) {
			for (int k: currentnodes[2]) {
				if (j == k) {
					continue;
				}
				if (p[j][k] != 2) {
					return 0;
				}
			}
		}
		*/
		prev = i;
		for (int j: currentnodes[1]) {
			ans[prev][j] = 1;
			ans[j][prev] = 1;
			prev = j;
		}
		prev = i;
		for (int j: currentnodes[2]) {
			ans[prev][j] = 1;
			ans[j][prev] = 1;
			prev = j;
		}
		if (prev == i) {
			continue;
		}
		ans[prev][i] = 1;
		ans[i][prev] = 1;
	}


	
	build(ans);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 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 348 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 96 ms 22036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 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 348 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 96 ms 22036 KB Output is correct
8 Correct 0 ms 344 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 4 ms 1116 KB Output is correct
13 Correct 99 ms 22040 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 48 ms 12308 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 25 ms 5844 KB Output is correct
21 Correct 98 ms 22100 KB Output is correct
22 Correct 95 ms 22036 KB Output is correct
23 Correct 109 ms 22096 KB Output is correct
24 Correct 97 ms 22040 KB Output is correct
25 Correct 42 ms 12296 KB Output is correct
26 Correct 41 ms 12112 KB Output is correct
27 Correct 116 ms 22032 KB Output is correct
28 Correct 100 ms 22056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 5 ms 1372 KB Output is correct
9 Correct 95 ms 22100 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 98 ms 22196 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 852 KB Output is correct
17 Correct 48 ms 12312 KB Output is correct
18 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
19 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 25 ms 5792 KB Output is correct
5 Correct 102 ms 22100 KB Output is correct
6 Correct 100 ms 22100 KB Output is correct
7 Correct 120 ms 22280 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 25 ms 5712 KB Output is correct
10 Correct 97 ms 22096 KB Output is correct
11 Correct 98 ms 22096 KB Output is correct
12 Correct 101 ms 22280 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 24 ms 5720 KB Too many ways to get from 23 to 253, should be 1 found no less than 2
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 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 348 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 96 ms 22036 KB Output is correct
8 Correct 0 ms 344 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 4 ms 1116 KB Output is correct
13 Correct 99 ms 22040 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 48 ms 12308 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 25 ms 5844 KB Output is correct
21 Correct 98 ms 22100 KB Output is correct
22 Correct 95 ms 22036 KB Output is correct
23 Correct 109 ms 22096 KB Output is correct
24 Correct 97 ms 22040 KB Output is correct
25 Correct 42 ms 12296 KB Output is correct
26 Correct 41 ms 12112 KB Output is correct
27 Correct 116 ms 22032 KB Output is correct
28 Correct 100 ms 22056 KB Output is correct
29 Correct 1 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 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 5 ms 1372 KB Output is correct
37 Correct 95 ms 22100 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 4 ms 1116 KB Output is correct
41 Correct 98 ms 22196 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 2 ms 852 KB Output is correct
45 Correct 48 ms 12312 KB Output is correct
46 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 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 348 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 96 ms 22036 KB Output is correct
8 Correct 0 ms 344 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 4 ms 1116 KB Output is correct
13 Correct 99 ms 22040 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 48 ms 12308 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 25 ms 5844 KB Output is correct
21 Correct 98 ms 22100 KB Output is correct
22 Correct 95 ms 22036 KB Output is correct
23 Correct 109 ms 22096 KB Output is correct
24 Correct 97 ms 22040 KB Output is correct
25 Correct 42 ms 12296 KB Output is correct
26 Correct 41 ms 12112 KB Output is correct
27 Correct 116 ms 22032 KB Output is correct
28 Correct 100 ms 22056 KB Output is correct
29 Correct 1 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 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 5 ms 1372 KB Output is correct
37 Correct 95 ms 22100 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 4 ms 1116 KB Output is correct
41 Correct 98 ms 22196 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 2 ms 852 KB Output is correct
45 Correct 48 ms 12312 KB Output is correct
46 Incorrect 0 ms 348 KB Answer gives possible 1 while actual possible 0
47 Halted 0 ms 0 KB -