Submission #586022

# Submission time Handle Problem Language Result Execution time Memory
586022 2022-06-29T18:16:51 Z serize Connecting Supertrees (IOI20_supertrees) C++17
40 / 100
245 ms 26588 KB
#include "supertrees.h"
#include<bits/stdc++.h>
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;

const int MAX = 1002;

int link[MAX];

inline int seek(int x){
    if(x == link[x]) return x;
    return link[x] = seek(link[x]);
}

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	std::vector<std::vector<int>> answer;
	for(int i = 0; i < n; i++) link[i] = i;
	int f = 0;
	bool flag = 1;
	for(auto i: p){
        int a = seek(f);
        for(int j = 0; j < n; j++){
            if(f!=j and i[j] == 1) flag = 0;
            if(i[j] != 0){
                int b = seek(j);
                link[b] = a;
            }
        }
        f++;
	}
	vector<int> cc[MAX];
	for(int i = 0; i < n; i++){
        cc[ link[i]  ].push_back(i);
	}
	int mat[n+1][n+1];
	memset(mat,0,sizeof(mat));
	bool good = 1;
	for(int i = 0; i < n; i++){
        int sz = (int)(cc[i].size());
        for(int j = 0; j < sz-1; j++){
            mat[ cc[i][j] ][ cc[i][j+1]  ] = 1;
            mat[ cc[i][j+1] ][ cc[i][j]  ] = 1;
        }
        if(flag and sz == 2){
            good = 0;
        }
        if(flag and sz > 2){
            mat[ cc[i][0]  ][  cc[i][ sz-1 ] ] = 1;
            mat[ cc[i][ sz-1 ]  ][ cc[i][0]  ] = 1;
        }
	}
 	for(int i = 0; i < n; i++){
        vector<int> asd;
        for(int j = 0; j < n; j++){
            asd.push_back(mat[i][j]);
        }
        answer.push_back(asd);
	}
    bool ok = 1;
    f = 0;
    for(auto i: p){
        for(int j = 0; j < n; j++){
             if(i[j] == 0 and link[f] == link[j]){
                ok = 0;
                break;
             }
        }
        f++;
        if(!ok) break;
	}
	if(ok and good){
        build(answer);
        return 1;
	}
	else return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 9 ms 1436 KB Output is correct
7 Correct 173 ms 26588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 9 ms 1436 KB Output is correct
7 Correct 173 ms 26588 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1468 KB Output is correct
13 Correct 225 ms 26228 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 980 KB Output is correct
17 Correct 91 ms 16264 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 45 ms 6936 KB Output is correct
21 Correct 198 ms 26244 KB Output is correct
22 Correct 214 ms 26220 KB Output is correct
23 Correct 200 ms 26260 KB Output is correct
24 Correct 192 ms 26272 KB Output is correct
25 Correct 79 ms 16280 KB Output is correct
26 Correct 97 ms 16244 KB Output is correct
27 Correct 236 ms 26232 KB Output is correct
28 Correct 245 ms 26200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 7 ms 1364 KB Output is correct
9 Correct 190 ms 26268 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1364 KB Output is correct
13 Correct 243 ms 26208 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 7 ms 980 KB Output is correct
17 Correct 90 ms 16260 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 46 ms 6956 KB Output is correct
22 Correct 180 ms 26208 KB Output is correct
23 Correct 241 ms 26224 KB Output is correct
24 Correct 220 ms 26188 KB Output is correct
25 Correct 99 ms 16332 KB Output is correct
26 Correct 74 ms 16292 KB Output is correct
27 Correct 208 ms 26192 KB Output is correct
28 Correct 199 ms 26188 KB Output is correct
29 Correct 109 ms 16356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 64 ms 6992 KB Output is correct
5 Correct 209 ms 26240 KB Output is correct
6 Correct 194 ms 26320 KB Output is correct
7 Correct 200 ms 26268 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 75 ms 7008 KB Output is correct
10 Correct 178 ms 26212 KB Output is correct
11 Correct 178 ms 26360 KB Output is correct
12 Correct 188 ms 26364 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 1 ms 212 KB Too few ways to get from 0 to 1, should be 2 found 1
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 9 ms 1436 KB Output is correct
7 Correct 173 ms 26588 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1468 KB Output is correct
13 Correct 225 ms 26228 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 980 KB Output is correct
17 Correct 91 ms 16264 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 45 ms 6936 KB Output is correct
21 Correct 198 ms 26244 KB Output is correct
22 Correct 214 ms 26220 KB Output is correct
23 Correct 200 ms 26260 KB Output is correct
24 Correct 192 ms 26272 KB Output is correct
25 Correct 79 ms 16280 KB Output is correct
26 Correct 97 ms 16244 KB Output is correct
27 Correct 236 ms 26232 KB Output is correct
28 Correct 245 ms 26200 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 7 ms 1364 KB Output is correct
37 Correct 190 ms 26268 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 8 ms 1364 KB Output is correct
41 Correct 243 ms 26208 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 7 ms 980 KB Output is correct
45 Correct 90 ms 16260 KB Output is correct
46 Correct 1 ms 300 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 46 ms 6956 KB Output is correct
50 Correct 180 ms 26208 KB Output is correct
51 Correct 241 ms 26224 KB Output is correct
52 Correct 220 ms 26188 KB Output is correct
53 Correct 99 ms 16332 KB Output is correct
54 Correct 74 ms 16292 KB Output is correct
55 Correct 208 ms 26192 KB Output is correct
56 Correct 199 ms 26188 KB Output is correct
57 Correct 109 ms 16356 KB Output is correct
58 Correct 1 ms 304 KB Output is correct
59 Correct 1 ms 308 KB Output is correct
60 Correct 6 ms 980 KB Output is correct
61 Correct 96 ms 16264 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Incorrect 0 ms 212 KB Too few ways to get from 3 to 4, should be 2 found 1
64 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 9 ms 1436 KB Output is correct
7 Correct 173 ms 26588 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1468 KB Output is correct
13 Correct 225 ms 26228 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 980 KB Output is correct
17 Correct 91 ms 16264 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 45 ms 6936 KB Output is correct
21 Correct 198 ms 26244 KB Output is correct
22 Correct 214 ms 26220 KB Output is correct
23 Correct 200 ms 26260 KB Output is correct
24 Correct 192 ms 26272 KB Output is correct
25 Correct 79 ms 16280 KB Output is correct
26 Correct 97 ms 16244 KB Output is correct
27 Correct 236 ms 26232 KB Output is correct
28 Correct 245 ms 26200 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 7 ms 1364 KB Output is correct
37 Correct 190 ms 26268 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 8 ms 1364 KB Output is correct
41 Correct 243 ms 26208 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 7 ms 980 KB Output is correct
45 Correct 90 ms 16260 KB Output is correct
46 Correct 1 ms 300 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 46 ms 6956 KB Output is correct
50 Correct 180 ms 26208 KB Output is correct
51 Correct 241 ms 26224 KB Output is correct
52 Correct 220 ms 26188 KB Output is correct
53 Correct 99 ms 16332 KB Output is correct
54 Correct 74 ms 16292 KB Output is correct
55 Correct 208 ms 26192 KB Output is correct
56 Correct 199 ms 26188 KB Output is correct
57 Correct 109 ms 16356 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 64 ms 6992 KB Output is correct
62 Correct 209 ms 26240 KB Output is correct
63 Correct 194 ms 26320 KB Output is correct
64 Correct 200 ms 26268 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 75 ms 7008 KB Output is correct
67 Correct 178 ms 26212 KB Output is correct
68 Correct 178 ms 26360 KB Output is correct
69 Correct 188 ms 26364 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Incorrect 1 ms 212 KB Too few ways to get from 0 to 1, should be 2 found 1
72 Halted 0 ms 0 KB -