답안 #303423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
303423 2020-09-20T09:58:08 Z mechfrog88 슈퍼트리 잇기 (IOI20_supertrees) C++14
40 / 100
297 ms 22264 KB
#include "supertrees.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int construct(vector<vector<int>> p) {
	int n = p.size();
	vector<vector<int>> ans(n,vector<int>(n));
	vector<bool> visited(n,false);
	bool ok = true;
	for (int z=0;z<n && ok;z++){
		if (visited[z]) continue;
		vector <ll> g1;
		vector <ll> g2;
		vector <ll> g3;
		for (int x=0;x<n && ok;x++){
			if (z == x) continue;
			if (p[z][x] == 1){
				g1.push_back(x);
				visited[x] = true;
				for (int x1=0;x1<n && ok;x1++){
					if (p[z][x1] != p[x][x1]){
						ok = false;
					}
				}
			}
			else if (p[z][x] == 2){
				g2.push_back(x);
				visited[x] = true;
				for (int x1=0;x1<n && ok;x1++){
					if (x1 == x) continue;
					if (p[z][x1] == 0 && p[x][x1] != 0){
						ok = false;
					}
					if (p[z][x1] != 0 && p[x][x1] != 2){
						ok = false;
					}
				}
			}
			else if (p[z][x] == 3){
				g3.push_back(x);
				visited[x] = true;
				for (int x1=0;x1<n && ok;x1++){
					if (x1 == x) continue;	
					if (p[z][x1] == 0 && p[x][x1] != 0){
						ok = false;
					}
					if (p[z][x1] != 0 && p[x][x1] != 3){
						ok = false;
					}
				}
			}
		}
		for (int x=0;x<g1.size();x++){
			ans[z][g1[x]] = 1;
			ans[g1[x]][z] = 1;
		}
		if (g2.size() < 2 && g2.size() > 0) ok = false;
		else if (g2.size() > 0){
			for (int x=0;x<g2.size()-1;x++){
				ans[g2[x]][g2[x+1]] = 1;
				ans[g2[x+1]][g2[x]] = 1;
			}
			ans[z][g2[0]] = 1;
			ans[g2[0]][z] = 1;
			ans[z][g2[g2.size()-1]] = 1;
			ans[g2[g2.size()-1]][z] = 1;
		}
		if (g3.size() < 3 && g3.size() > 0) ok = false;
		else if (g3.size() > 0){
			for (int x=0;x<g3.size()-1;x++){
				ans[g3[x]][g3[x+1]] = 1;
				ans[g3[x+1]][g3[x]] = 1;
			}
			ans[z][g3[0]] = 1;
			ans[g3[0]][z] = 1;
			ans[z][g3[g3.size()-1]] = 1;
			ans[g3[g3.size()-1]][z] = 1;
			ans[g3[0]][g3[g3.size()-1]] = 1;
			ans[g3[g3.size()-1]][g3[0]] = 1;
		}
	}
	if (ok){
		build(ans);
		return 1;
	} else {
		return 0;
	}
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:54:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   for (int x=0;x<g1.size();x++){
      |                ~^~~~~~~~~~
supertrees.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |    for (int x=0;x<g2.size()-1;x++){
      |                 ~^~~~~~~~~~~~
supertrees.cpp:71:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |    for (int x=0;x<g3.size()-1;x++){
      |                 ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 16 ms 1152 KB Output is correct
7 Correct 257 ms 22140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 16 ms 1152 KB Output is correct
7 Correct 257 ms 22140 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 10 ms 1152 KB Output is correct
13 Correct 245 ms 22136 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 112 ms 12152 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 64 ms 5880 KB Output is correct
21 Correct 251 ms 22136 KB Output is correct
22 Correct 297 ms 22136 KB Output is correct
23 Correct 255 ms 22136 KB Output is correct
24 Correct 260 ms 22264 KB Output is correct
25 Correct 110 ms 12120 KB Output is correct
26 Correct 104 ms 12152 KB Output is correct
27 Correct 249 ms 22136 KB Output is correct
28 Correct 246 ms 22136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 11 ms 1152 KB Output is correct
9 Correct 272 ms 22232 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 10 ms 1152 KB Output is correct
13 Correct 247 ms 22136 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 107 ms 12152 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 64 ms 5752 KB Output is correct
22 Correct 257 ms 22160 KB Output is correct
23 Correct 243 ms 22136 KB Output is correct
24 Correct 248 ms 22136 KB Output is correct
25 Correct 135 ms 12152 KB Output is correct
26 Correct 107 ms 12156 KB Output is correct
27 Correct 245 ms 22140 KB Output is correct
28 Correct 255 ms 22136 KB Output is correct
29 Correct 114 ms 12152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 83 ms 5752 KB Output is correct
5 Correct 244 ms 22136 KB Output is correct
6 Correct 247 ms 22140 KB Output is correct
7 Correct 279 ms 22136 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 74 ms 5752 KB Output is correct
10 Correct 250 ms 22264 KB Output is correct
11 Correct 248 ms 22100 KB Output is correct
12 Correct 266 ms 22136 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Incorrect 26 ms 3320 KB Answer gives possible 0 while actual possible 1
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 16 ms 1152 KB Output is correct
7 Correct 257 ms 22140 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 10 ms 1152 KB Output is correct
13 Correct 245 ms 22136 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 112 ms 12152 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 64 ms 5880 KB Output is correct
21 Correct 251 ms 22136 KB Output is correct
22 Correct 297 ms 22136 KB Output is correct
23 Correct 255 ms 22136 KB Output is correct
24 Correct 260 ms 22264 KB Output is correct
25 Correct 110 ms 12120 KB Output is correct
26 Correct 104 ms 12152 KB Output is correct
27 Correct 249 ms 22136 KB Output is correct
28 Correct 246 ms 22136 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 1 ms 256 KB Output is correct
31 Correct 0 ms 256 KB Output is correct
32 Correct 0 ms 256 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 1 ms 256 KB Output is correct
36 Correct 11 ms 1152 KB Output is correct
37 Correct 272 ms 22232 KB Output is correct
38 Correct 1 ms 256 KB Output is correct
39 Correct 0 ms 256 KB Output is correct
40 Correct 10 ms 1152 KB Output is correct
41 Correct 247 ms 22136 KB Output is correct
42 Correct 1 ms 256 KB Output is correct
43 Correct 0 ms 256 KB Output is correct
44 Correct 5 ms 768 KB Output is correct
45 Correct 107 ms 12152 KB Output is correct
46 Correct 1 ms 256 KB Output is correct
47 Correct 1 ms 256 KB Output is correct
48 Correct 1 ms 256 KB Output is correct
49 Correct 64 ms 5752 KB Output is correct
50 Correct 257 ms 22160 KB Output is correct
51 Correct 243 ms 22136 KB Output is correct
52 Correct 248 ms 22136 KB Output is correct
53 Correct 135 ms 12152 KB Output is correct
54 Correct 107 ms 12156 KB Output is correct
55 Correct 245 ms 22140 KB Output is correct
56 Correct 255 ms 22136 KB Output is correct
57 Correct 114 ms 12152 KB Output is correct
58 Correct 1 ms 256 KB Output is correct
59 Correct 1 ms 256 KB Output is correct
60 Correct 5 ms 768 KB Output is correct
61 Correct 113 ms 12152 KB Output is correct
62 Correct 1 ms 256 KB Output is correct
63 Correct 1 ms 256 KB Output is correct
64 Correct 1 ms 256 KB Output is correct
65 Incorrect 26 ms 3320 KB Answer gives possible 0 while actual possible 1
66 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 16 ms 1152 KB Output is correct
7 Correct 257 ms 22140 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 10 ms 1152 KB Output is correct
13 Correct 245 ms 22136 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 5 ms 768 KB Output is correct
17 Correct 112 ms 12152 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 64 ms 5880 KB Output is correct
21 Correct 251 ms 22136 KB Output is correct
22 Correct 297 ms 22136 KB Output is correct
23 Correct 255 ms 22136 KB Output is correct
24 Correct 260 ms 22264 KB Output is correct
25 Correct 110 ms 12120 KB Output is correct
26 Correct 104 ms 12152 KB Output is correct
27 Correct 249 ms 22136 KB Output is correct
28 Correct 246 ms 22136 KB Output is correct
29 Correct 1 ms 256 KB Output is correct
30 Correct 1 ms 256 KB Output is correct
31 Correct 0 ms 256 KB Output is correct
32 Correct 0 ms 256 KB Output is correct
33 Correct 1 ms 256 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 1 ms 256 KB Output is correct
36 Correct 11 ms 1152 KB Output is correct
37 Correct 272 ms 22232 KB Output is correct
38 Correct 1 ms 256 KB Output is correct
39 Correct 0 ms 256 KB Output is correct
40 Correct 10 ms 1152 KB Output is correct
41 Correct 247 ms 22136 KB Output is correct
42 Correct 1 ms 256 KB Output is correct
43 Correct 0 ms 256 KB Output is correct
44 Correct 5 ms 768 KB Output is correct
45 Correct 107 ms 12152 KB Output is correct
46 Correct 1 ms 256 KB Output is correct
47 Correct 1 ms 256 KB Output is correct
48 Correct 1 ms 256 KB Output is correct
49 Correct 64 ms 5752 KB Output is correct
50 Correct 257 ms 22160 KB Output is correct
51 Correct 243 ms 22136 KB Output is correct
52 Correct 248 ms 22136 KB Output is correct
53 Correct 135 ms 12152 KB Output is correct
54 Correct 107 ms 12156 KB Output is correct
55 Correct 245 ms 22140 KB Output is correct
56 Correct 255 ms 22136 KB Output is correct
57 Correct 114 ms 12152 KB Output is correct
58 Correct 1 ms 256 KB Output is correct
59 Correct 1 ms 256 KB Output is correct
60 Correct 1 ms 256 KB Output is correct
61 Correct 83 ms 5752 KB Output is correct
62 Correct 244 ms 22136 KB Output is correct
63 Correct 247 ms 22140 KB Output is correct
64 Correct 279 ms 22136 KB Output is correct
65 Correct 0 ms 256 KB Output is correct
66 Correct 74 ms 5752 KB Output is correct
67 Correct 250 ms 22264 KB Output is correct
68 Correct 248 ms 22100 KB Output is correct
69 Correct 266 ms 22136 KB Output is correct
70 Correct 0 ms 256 KB Output is correct
71 Correct 1 ms 256 KB Output is correct
72 Correct 0 ms 256 KB Output is correct
73 Incorrect 26 ms 3320 KB Answer gives possible 0 while actual possible 1
74 Halted 0 ms 0 KB -