#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
#define lli int
#define rep(i,a,b) for (lli i = (a); i <= (b); i++)
#define repa(i,a,b) for (lli i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl;
#define debugsl(a) cout << #a << " = " << a << ", ";
#define MAX 1000
lli n,m,ult,pos,pp,cant;
lli visitados[MAX+2];
vector<lli> cabezas;
vector<vector<lli> > planos;
bool compara(lli a, lli b, lli tipo,vector<vector<lli> > &pl) {
lli q,w;
rep(i,0,n-1) {
if (pl[a][i] == 3 || pl[b][i] == 3) return false;
if (tipo == 1) {
if (pl[a][i] != pl[b][i]) return false;
}
else {
if (pl[a][i] > 0) q = 1;
else q = 0;
if (pl[b][i] > 0) w = 1;
else w = 0;
if (q != w) return false;
}
}
return true;
}
int construct(std::vector<std::vector<int>> p) {
n = p.size();
planos = vector< vector<lli> > (n, vector<int> (n,0));
//hacer cabezas
rep(i,0,n-1) {
if (visitados[i] == 0) {
cabezas.push_back(i);
visitados[i] = 1;
rep(j,0,n-1) {
if (p[i][j] == 3) return 0;
if (j == i || p[i][j] != 1) continue;
visitados[j] = 1;
if (!compara(i,j,1,p)) return 0;
else {
planos[i][j] = 1;
planos[j][i] = 1;
}
}
}
}
m = cabezas.size();
rep(i,0,m-1) {
pos = cabezas[i];
if (visitados[pos] < 2) {
ult = pos;
visitados[pos] = 2;
cant = 0;
rep(j,0,m-1) {
pp = cabezas[j];
if (pos == pp || p[pos][pp] != 2) continue;
cant++;
visitados[pp] = 2;
if (!compara(pos,pp,2,p)) return 0;
else {
planos[ult][pp] = 1;
planos[pp][ult] = 1;
ult = pp;
}
}
if (cant == 1) return 0;
if (pos != ult) {
planos[pos][ult] = 1;
planos[ult][pos] = 1;
}
}
}
build(planos);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
12 ms |
1100 KB |
Output is correct |
7 |
Correct |
220 ms |
21940 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
12 ms |
1100 KB |
Output is correct |
7 |
Correct |
220 ms |
21940 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
236 KB |
Output is correct |
12 |
Correct |
9 ms |
1120 KB |
Output is correct |
13 |
Correct |
231 ms |
22012 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
6 ms |
716 KB |
Output is correct |
17 |
Correct |
96 ms |
12044 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
69 ms |
5748 KB |
Output is correct |
21 |
Correct |
228 ms |
21956 KB |
Output is correct |
22 |
Correct |
219 ms |
21956 KB |
Output is correct |
23 |
Correct |
239 ms |
22132 KB |
Output is correct |
24 |
Correct |
221 ms |
22084 KB |
Output is correct |
25 |
Correct |
96 ms |
12032 KB |
Output is correct |
26 |
Correct |
95 ms |
12036 KB |
Output is correct |
27 |
Correct |
229 ms |
22032 KB |
Output is correct |
28 |
Correct |
226 ms |
22028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
10 ms |
1100 KB |
Output is correct |
9 |
Correct |
236 ms |
22232 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
9 ms |
1124 KB |
Output is correct |
13 |
Correct |
219 ms |
22156 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
6 ms |
840 KB |
Output is correct |
17 |
Correct |
98 ms |
13624 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
58 ms |
6128 KB |
Output is correct |
22 |
Correct |
232 ms |
22692 KB |
Output is correct |
23 |
Correct |
221 ms |
22604 KB |
Output is correct |
24 |
Correct |
315 ms |
22596 KB |
Output is correct |
25 |
Correct |
140 ms |
13556 KB |
Output is correct |
26 |
Correct |
140 ms |
13460 KB |
Output is correct |
27 |
Correct |
221 ms |
22524 KB |
Output is correct |
28 |
Correct |
259 ms |
22596 KB |
Output is correct |
29 |
Correct |
99 ms |
13532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
56 ms |
5760 KB |
Output is correct |
5 |
Correct |
254 ms |
21956 KB |
Output is correct |
6 |
Correct |
230 ms |
22084 KB |
Output is correct |
7 |
Correct |
231 ms |
22024 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
60 ms |
5760 KB |
Output is correct |
10 |
Correct |
277 ms |
21960 KB |
Output is correct |
11 |
Correct |
219 ms |
22036 KB |
Output is correct |
12 |
Correct |
230 ms |
22084 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
56 ms |
5764 KB |
Output is correct |
17 |
Correct |
223 ms |
22028 KB |
Output is correct |
18 |
Correct |
271 ms |
22028 KB |
Output is correct |
19 |
Correct |
223 ms |
22048 KB |
Output is correct |
20 |
Correct |
290 ms |
21956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
12 ms |
1100 KB |
Output is correct |
7 |
Correct |
220 ms |
21940 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
236 KB |
Output is correct |
12 |
Correct |
9 ms |
1120 KB |
Output is correct |
13 |
Correct |
231 ms |
22012 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
6 ms |
716 KB |
Output is correct |
17 |
Correct |
96 ms |
12044 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
69 ms |
5748 KB |
Output is correct |
21 |
Correct |
228 ms |
21956 KB |
Output is correct |
22 |
Correct |
219 ms |
21956 KB |
Output is correct |
23 |
Correct |
239 ms |
22132 KB |
Output is correct |
24 |
Correct |
221 ms |
22084 KB |
Output is correct |
25 |
Correct |
96 ms |
12032 KB |
Output is correct |
26 |
Correct |
95 ms |
12036 KB |
Output is correct |
27 |
Correct |
229 ms |
22032 KB |
Output is correct |
28 |
Correct |
226 ms |
22028 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
10 ms |
1100 KB |
Output is correct |
37 |
Correct |
236 ms |
22232 KB |
Output is correct |
38 |
Correct |
0 ms |
204 KB |
Output is correct |
39 |
Correct |
0 ms |
204 KB |
Output is correct |
40 |
Correct |
9 ms |
1124 KB |
Output is correct |
41 |
Correct |
219 ms |
22156 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
6 ms |
840 KB |
Output is correct |
45 |
Correct |
98 ms |
13624 KB |
Output is correct |
46 |
Correct |
1 ms |
204 KB |
Output is correct |
47 |
Correct |
1 ms |
204 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
58 ms |
6128 KB |
Output is correct |
50 |
Correct |
232 ms |
22692 KB |
Output is correct |
51 |
Correct |
221 ms |
22604 KB |
Output is correct |
52 |
Correct |
315 ms |
22596 KB |
Output is correct |
53 |
Correct |
140 ms |
13556 KB |
Output is correct |
54 |
Correct |
140 ms |
13460 KB |
Output is correct |
55 |
Correct |
221 ms |
22524 KB |
Output is correct |
56 |
Correct |
259 ms |
22596 KB |
Output is correct |
57 |
Correct |
99 ms |
13532 KB |
Output is correct |
58 |
Correct |
1 ms |
292 KB |
Output is correct |
59 |
Correct |
1 ms |
204 KB |
Output is correct |
60 |
Correct |
5 ms |
844 KB |
Output is correct |
61 |
Correct |
100 ms |
13580 KB |
Output is correct |
62 |
Correct |
1 ms |
204 KB |
Output is correct |
63 |
Correct |
1 ms |
204 KB |
Output is correct |
64 |
Correct |
1 ms |
204 KB |
Output is correct |
65 |
Correct |
58 ms |
6084 KB |
Output is correct |
66 |
Correct |
93 ms |
13432 KB |
Output is correct |
67 |
Correct |
91 ms |
13464 KB |
Output is correct |
68 |
Correct |
92 ms |
13596 KB |
Output is correct |
69 |
Correct |
96 ms |
13416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
12 ms |
1100 KB |
Output is correct |
7 |
Correct |
220 ms |
21940 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
236 KB |
Output is correct |
12 |
Correct |
9 ms |
1120 KB |
Output is correct |
13 |
Correct |
231 ms |
22012 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
6 ms |
716 KB |
Output is correct |
17 |
Correct |
96 ms |
12044 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
69 ms |
5748 KB |
Output is correct |
21 |
Correct |
228 ms |
21956 KB |
Output is correct |
22 |
Correct |
219 ms |
21956 KB |
Output is correct |
23 |
Correct |
239 ms |
22132 KB |
Output is correct |
24 |
Correct |
221 ms |
22084 KB |
Output is correct |
25 |
Correct |
96 ms |
12032 KB |
Output is correct |
26 |
Correct |
95 ms |
12036 KB |
Output is correct |
27 |
Correct |
229 ms |
22032 KB |
Output is correct |
28 |
Correct |
226 ms |
22028 KB |
Output is correct |
29 |
Correct |
1 ms |
204 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
1 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
10 ms |
1100 KB |
Output is correct |
37 |
Correct |
236 ms |
22232 KB |
Output is correct |
38 |
Correct |
0 ms |
204 KB |
Output is correct |
39 |
Correct |
0 ms |
204 KB |
Output is correct |
40 |
Correct |
9 ms |
1124 KB |
Output is correct |
41 |
Correct |
219 ms |
22156 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
6 ms |
840 KB |
Output is correct |
45 |
Correct |
98 ms |
13624 KB |
Output is correct |
46 |
Correct |
1 ms |
204 KB |
Output is correct |
47 |
Correct |
1 ms |
204 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
58 ms |
6128 KB |
Output is correct |
50 |
Correct |
232 ms |
22692 KB |
Output is correct |
51 |
Correct |
221 ms |
22604 KB |
Output is correct |
52 |
Correct |
315 ms |
22596 KB |
Output is correct |
53 |
Correct |
140 ms |
13556 KB |
Output is correct |
54 |
Correct |
140 ms |
13460 KB |
Output is correct |
55 |
Correct |
221 ms |
22524 KB |
Output is correct |
56 |
Correct |
259 ms |
22596 KB |
Output is correct |
57 |
Correct |
99 ms |
13532 KB |
Output is correct |
58 |
Correct |
1 ms |
204 KB |
Output is correct |
59 |
Correct |
1 ms |
204 KB |
Output is correct |
60 |
Correct |
1 ms |
204 KB |
Output is correct |
61 |
Correct |
56 ms |
5760 KB |
Output is correct |
62 |
Correct |
254 ms |
21956 KB |
Output is correct |
63 |
Correct |
230 ms |
22084 KB |
Output is correct |
64 |
Correct |
231 ms |
22024 KB |
Output is correct |
65 |
Correct |
1 ms |
204 KB |
Output is correct |
66 |
Correct |
60 ms |
5760 KB |
Output is correct |
67 |
Correct |
277 ms |
21960 KB |
Output is correct |
68 |
Correct |
219 ms |
22036 KB |
Output is correct |
69 |
Correct |
230 ms |
22084 KB |
Output is correct |
70 |
Correct |
1 ms |
204 KB |
Output is correct |
71 |
Correct |
1 ms |
204 KB |
Output is correct |
72 |
Correct |
1 ms |
204 KB |
Output is correct |
73 |
Correct |
56 ms |
5764 KB |
Output is correct |
74 |
Correct |
223 ms |
22028 KB |
Output is correct |
75 |
Correct |
271 ms |
22028 KB |
Output is correct |
76 |
Correct |
223 ms |
22048 KB |
Output is correct |
77 |
Correct |
290 ms |
21956 KB |
Output is correct |
78 |
Correct |
1 ms |
292 KB |
Output is correct |
79 |
Correct |
1 ms |
204 KB |
Output is correct |
80 |
Correct |
5 ms |
844 KB |
Output is correct |
81 |
Correct |
100 ms |
13580 KB |
Output is correct |
82 |
Correct |
1 ms |
204 KB |
Output is correct |
83 |
Correct |
1 ms |
204 KB |
Output is correct |
84 |
Correct |
1 ms |
204 KB |
Output is correct |
85 |
Correct |
58 ms |
6084 KB |
Output is correct |
86 |
Correct |
93 ms |
13432 KB |
Output is correct |
87 |
Correct |
91 ms |
13464 KB |
Output is correct |
88 |
Correct |
92 ms |
13596 KB |
Output is correct |
89 |
Correct |
96 ms |
13416 KB |
Output is correct |
90 |
Correct |
1 ms |
204 KB |
Output is correct |
91 |
Correct |
1 ms |
204 KB |
Output is correct |
92 |
Correct |
5 ms |
844 KB |
Output is correct |
93 |
Correct |
95 ms |
13464 KB |
Output is correct |
94 |
Correct |
1 ms |
204 KB |
Output is correct |
95 |
Correct |
1 ms |
204 KB |
Output is correct |
96 |
Correct |
1 ms |
204 KB |
Output is correct |
97 |
Correct |
24 ms |
3660 KB |
Output is correct |
98 |
Correct |
97 ms |
13988 KB |
Output is correct |
99 |
Correct |
90 ms |
14020 KB |
Output is correct |
100 |
Correct |
91 ms |
14064 KB |
Output is correct |
101 |
Correct |
92 ms |
14076 KB |
Output is correct |
102 |
Correct |
89 ms |
14020 KB |
Output is correct |
103 |
Correct |
97 ms |
14064 KB |
Output is correct |
104 |
Correct |
91 ms |
14076 KB |
Output is correct |
105 |
Correct |
96 ms |
14064 KB |
Output is correct |