#include "supertrees.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
int a[1005][1005], i, j, f[1005], a2, a3, k, l, cnt, c, pr[1005];
vector<int> s, d, e;
int construct(std::vector<std::vector<int>> p)
{
int n = p.size();
std::vector<std::vector<int>> answer;
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
{
if(p[i][j] == 3) return 0;
if(p[i][j] != p[j][i]) return 0;
}
for(i = 0; i < n; i++)
{
a2 = 0;
for(j = 0; j < n; j++)
if(p[i][j] == 2) a2 = 1;
if(!f[i])
{
e.clear(); d.clear();
if(a2) k = 2; else k = 1;
f[i] = 1, l = i, cnt = 0;
if(k == 2)
for(int b = 0; b < n; b++)
{
if(!f[b] && p[i][b] == 1) { f[b] = 1, a[i][b] = a[b][i] = 1; if(k == 2) e.pb(b); else d.pb(b); pr[b] = i; }
if(f[b] == 2 && p[i][b]) return 0;
}
d.pb(i);
for(j = 0; j < n; j++)
if(!f[j] && p[l][j] == k)
{
f[j] = 1;
d.pb(j);
a[l][j] = a[j][l] = 1;
for(int b = 0; b < n; b++)
{
if(!f[b] && p[j][b] == 1) { f[b] = 1, a[j][b] = a[b][j] = 1; if(k == 2) e.pb(b); else d.pb(b); pr[b] = j; }
if(f[b] == 2 && p[j][b]) return 0;
}
l = j;
cnt++;
}
else if(f[j] == 2 && p[i][j]) return 0;
if(k == 2 && cnt < 2) return 0;
if(k == 2) a[l][i] = a[i][l] = 1;
for(j = 0; j < n; j++)
if(f[j] == 1) f[j] = 2;
for(auto x : d)
for(auto y : e)
if(!a[x][y] && p[x][y] != k) return 0;
for(auto x : d)
for(auto y : d)
if(x != y && p[x][y] != k) return 0;
for(auto x : e)
for(auto y : e)
{
if(x != y && pr[x] != pr[y] && p[x][y] != k) return 0;
if(x != y && pr[x] == pr[y] && p[x][y] != 1) return 0;
}
}
}
for(i = 0; i < n; i++)
{
for(j = 0; j < n; j++)
s.push_back(a[i][j]);
answer.push_back(s);
s.clear();
}
build(answer);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 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 |
7 ms |
3416 KB |
Output is correct |
7 |
Correct |
156 ms |
27988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 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 |
7 ms |
3416 KB |
Output is correct |
7 |
Correct |
156 ms |
27988 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 |
6 ms |
1372 KB |
Output is correct |
13 |
Correct |
151 ms |
24116 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
612 KB |
Output is correct |
16 |
Correct |
3 ms |
2904 KB |
Output is correct |
17 |
Correct |
61 ms |
13204 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
544 KB |
Output is correct |
20 |
Correct |
38 ms |
8536 KB |
Output is correct |
21 |
Correct |
149 ms |
27984 KB |
Output is correct |
22 |
Correct |
166 ms |
27760 KB |
Output is correct |
23 |
Correct |
158 ms |
28164 KB |
Output is correct |
24 |
Correct |
170 ms |
26308 KB |
Output is correct |
25 |
Incorrect |
151 ms |
28240 KB |
Answer gives possible 1 while actual possible 0 |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
7 ms |
1372 KB |
Output is correct |
9 |
Correct |
156 ms |
24352 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
7 ms |
3420 KB |
Output is correct |
13 |
Correct |
156 ms |
27972 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
5 ms |
2908 KB |
Output is correct |
17 |
Correct |
63 ms |
13244 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
41 ms |
8588 KB |
Output is correct |
22 |
Correct |
179 ms |
27848 KB |
Output is correct |
23 |
Correct |
162 ms |
27984 KB |
Output is correct |
24 |
Correct |
169 ms |
28032 KB |
Output is correct |
25 |
Correct |
68 ms |
12372 KB |
Output is correct |
26 |
Correct |
62 ms |
12816 KB |
Output is correct |
27 |
Correct |
165 ms |
27996 KB |
Output is correct |
28 |
Correct |
174 ms |
27984 KB |
Output is correct |
29 |
Correct |
65 ms |
12372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
448 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
40 ms |
8516 KB |
Output is correct |
5 |
Correct |
153 ms |
27984 KB |
Output is correct |
6 |
Correct |
160 ms |
27724 KB |
Output is correct |
7 |
Correct |
158 ms |
28044 KB |
Output is correct |
8 |
Correct |
1 ms |
352 KB |
Output is correct |
9 |
Correct |
40 ms |
8560 KB |
Output is correct |
10 |
Correct |
176 ms |
27996 KB |
Output is correct |
11 |
Correct |
157 ms |
27920 KB |
Output is correct |
12 |
Correct |
189 ms |
27860 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
38 ms |
8456 KB |
Output is correct |
17 |
Correct |
153 ms |
28052 KB |
Output is correct |
18 |
Correct |
151 ms |
27732 KB |
Output is correct |
19 |
Correct |
160 ms |
27728 KB |
Output is correct |
20 |
Correct |
150 ms |
26204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 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 |
7 ms |
3416 KB |
Output is correct |
7 |
Correct |
156 ms |
27988 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 |
6 ms |
1372 KB |
Output is correct |
13 |
Correct |
151 ms |
24116 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
612 KB |
Output is correct |
16 |
Correct |
3 ms |
2904 KB |
Output is correct |
17 |
Correct |
61 ms |
13204 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
544 KB |
Output is correct |
20 |
Correct |
38 ms |
8536 KB |
Output is correct |
21 |
Correct |
149 ms |
27984 KB |
Output is correct |
22 |
Correct |
166 ms |
27760 KB |
Output is correct |
23 |
Correct |
158 ms |
28164 KB |
Output is correct |
24 |
Correct |
170 ms |
26308 KB |
Output is correct |
25 |
Incorrect |
151 ms |
28240 KB |
Answer gives possible 1 while actual possible 0 |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 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 |
7 ms |
3416 KB |
Output is correct |
7 |
Correct |
156 ms |
27988 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 |
6 ms |
1372 KB |
Output is correct |
13 |
Correct |
151 ms |
24116 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
612 KB |
Output is correct |
16 |
Correct |
3 ms |
2904 KB |
Output is correct |
17 |
Correct |
61 ms |
13204 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
544 KB |
Output is correct |
20 |
Correct |
38 ms |
8536 KB |
Output is correct |
21 |
Correct |
149 ms |
27984 KB |
Output is correct |
22 |
Correct |
166 ms |
27760 KB |
Output is correct |
23 |
Correct |
158 ms |
28164 KB |
Output is correct |
24 |
Correct |
170 ms |
26308 KB |
Output is correct |
25 |
Incorrect |
151 ms |
28240 KB |
Answer gives possible 1 while actual possible 0 |
26 |
Halted |
0 ms |
0 KB |
- |