Submission #771105

# Submission time Handle Problem Language Result Execution time Memory
771105 2023-07-02T12:54:17 Z OrazB Connecting Supertrees (IOI20_supertrees) C++14
56 / 100
177 ms 30428 KB
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
#define N 100005
#define wr cout << "Continue debugging\n";
#define all(x) (x).begin(), (x).end()
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
 
vector<int> vec[N];
 
int construct(vector<vector<int>> p){
	int n = p.size();
	vector<vector<int>> b(n, vector<int>(n, 0));
	vector<int> vis(n, 0), ok(n, 0);
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (vis[i]){ 
			if (p[i] != vec[vis[i]]) return 0;
			continue;
		}
		cnt++;
		for (int j = 0; j < n; j++){
			if (p[i][j] and i != j){
				if (p[i][j] == 1){
					b[i][j] = b[j][i] = 1;
					vis[j] = cnt;
				}
			}
			vec[cnt].pb(p[i][j]);
		}
	}
	for (int i = 0; i < n; i++){
		if (vis[i] or ok[i]) continue;
		deque<int> v;
		for (int j = 0; j < n; j++){
			if (p[i][j] == 2 and !vis[j]){
				if (ok[j]) return 0;
				ok[j] = 1;
				v.pb(j);
			}
		}
		if (!v.size()) continue;
		if (v.size() == 1) return 0;
		v.push_front(i);
		for (int j = 0; j < (int)v.size(); j++){
			for (int k = j+1; k < v.size(); k++) if (p[v[j]][v[k]] != 2) return 0;
		}
		b[v[0]][v.back()] = b[v.back()][v[0]] = 1;
		for (int j = 1; j < (int)v.size(); j++){
			b[v[j-1]][v[j]] = b[v[j]][v[j-1]] = 1;
		}
	}
	// for (int i = 0; i < n; i++){
	// 	for (int j = 0; j < n; j++) cout << b[i][j] << ' ';
	// 	cout << '\n';
	// }
	build(b);
	return 1;
}
// int main ()
// {
// 	int n;
// 	cin >> n;
// 	vector<vector<int>> p(n, vector<int>(n));
// 	for (int i = 0; i < n; i++){
// 		for (int j = 0; j < n; j++) cin >> p[i][j];
// 	}
// 	int x = construct(p);
// }	

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:50:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |    for (int k = j+1; k < v.size(); k++) if (p[v[j]][v[k]] != 2) return 0;
      |                      ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2648 KB Output is correct
6 Correct 7 ms 3540 KB Output is correct
7 Correct 153 ms 26332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2648 KB Output is correct
6 Correct 7 ms 3540 KB Output is correct
7 Correct 153 ms 26332 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 8 ms 3796 KB Output is correct
13 Correct 160 ms 30380 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 4 ms 3156 KB Output is correct
17 Correct 76 ms 16420 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 1 ms 2644 KB Output is correct
20 Correct 45 ms 8828 KB Output is correct
21 Correct 158 ms 26284 KB Output is correct
22 Correct 158 ms 27940 KB Output is correct
23 Correct 164 ms 26340 KB Output is correct
24 Correct 161 ms 30068 KB Output is correct
25 Correct 72 ms 16432 KB Output is correct
26 Correct 72 ms 17568 KB Output is correct
27 Correct 166 ms 26316 KB Output is correct
28 Correct 160 ms 30172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 8 ms 3760 KB Output is correct
9 Correct 161 ms 30304 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 8 ms 3800 KB Output is correct
13 Correct 157 ms 30324 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 80 ms 20400 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 1 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 41 ms 9604 KB Output is correct
22 Correct 165 ms 30284 KB Output is correct
23 Correct 161 ms 30288 KB Output is correct
24 Correct 177 ms 30300 KB Output is correct
25 Correct 75 ms 20440 KB Output is correct
26 Incorrect 160 ms 30380 KB Answer gives possible 1 while actual possible 0
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 40 ms 8740 KB Output is correct
5 Correct 161 ms 26400 KB Output is correct
6 Correct 164 ms 27956 KB Output is correct
7 Correct 163 ms 26276 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 41 ms 9540 KB Output is correct
10 Correct 161 ms 30384 KB Output is correct
11 Correct 168 ms 30428 KB Output is correct
12 Correct 166 ms 30376 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 40 ms 9380 KB Output is correct
17 Correct 165 ms 30388 KB Output is correct
18 Correct 170 ms 28448 KB Output is correct
19 Correct 161 ms 28748 KB Output is correct
20 Correct 160 ms 30260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2648 KB Output is correct
6 Correct 7 ms 3540 KB Output is correct
7 Correct 153 ms 26332 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 8 ms 3796 KB Output is correct
13 Correct 160 ms 30380 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 4 ms 3156 KB Output is correct
17 Correct 76 ms 16420 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 1 ms 2644 KB Output is correct
20 Correct 45 ms 8828 KB Output is correct
21 Correct 158 ms 26284 KB Output is correct
22 Correct 158 ms 27940 KB Output is correct
23 Correct 164 ms 26340 KB Output is correct
24 Correct 161 ms 30068 KB Output is correct
25 Correct 72 ms 16432 KB Output is correct
26 Correct 72 ms 17568 KB Output is correct
27 Correct 166 ms 26316 KB Output is correct
28 Correct 160 ms 30172 KB Output is correct
29 Correct 1 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2772 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 2 ms 2644 KB Output is correct
35 Correct 1 ms 2644 KB Output is correct
36 Correct 8 ms 3760 KB Output is correct
37 Correct 161 ms 30304 KB Output is correct
38 Correct 1 ms 2644 KB Output is correct
39 Correct 1 ms 2644 KB Output is correct
40 Correct 8 ms 3800 KB Output is correct
41 Correct 157 ms 30324 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 1 ms 2644 KB Output is correct
44 Correct 5 ms 3412 KB Output is correct
45 Correct 80 ms 20400 KB Output is correct
46 Correct 1 ms 2644 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 1 ms 2644 KB Output is correct
49 Correct 41 ms 9604 KB Output is correct
50 Correct 165 ms 30284 KB Output is correct
51 Correct 161 ms 30288 KB Output is correct
52 Correct 177 ms 30300 KB Output is correct
53 Correct 75 ms 20440 KB Output is correct
54 Incorrect 160 ms 30380 KB Answer gives possible 1 while actual possible 0
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 2648 KB Output is correct
6 Correct 7 ms 3540 KB Output is correct
7 Correct 153 ms 26332 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 8 ms 3796 KB Output is correct
13 Correct 160 ms 30380 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 4 ms 3156 KB Output is correct
17 Correct 76 ms 16420 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 1 ms 2644 KB Output is correct
20 Correct 45 ms 8828 KB Output is correct
21 Correct 158 ms 26284 KB Output is correct
22 Correct 158 ms 27940 KB Output is correct
23 Correct 164 ms 26340 KB Output is correct
24 Correct 161 ms 30068 KB Output is correct
25 Correct 72 ms 16432 KB Output is correct
26 Correct 72 ms 17568 KB Output is correct
27 Correct 166 ms 26316 KB Output is correct
28 Correct 160 ms 30172 KB Output is correct
29 Correct 1 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2772 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 2 ms 2644 KB Output is correct
35 Correct 1 ms 2644 KB Output is correct
36 Correct 8 ms 3760 KB Output is correct
37 Correct 161 ms 30304 KB Output is correct
38 Correct 1 ms 2644 KB Output is correct
39 Correct 1 ms 2644 KB Output is correct
40 Correct 8 ms 3800 KB Output is correct
41 Correct 157 ms 30324 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 1 ms 2644 KB Output is correct
44 Correct 5 ms 3412 KB Output is correct
45 Correct 80 ms 20400 KB Output is correct
46 Correct 1 ms 2644 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 1 ms 2644 KB Output is correct
49 Correct 41 ms 9604 KB Output is correct
50 Correct 165 ms 30284 KB Output is correct
51 Correct 161 ms 30288 KB Output is correct
52 Correct 177 ms 30300 KB Output is correct
53 Correct 75 ms 20440 KB Output is correct
54 Incorrect 160 ms 30380 KB Answer gives possible 1 while actual possible 0
55 Halted 0 ms 0 KB -