#include "supertrees.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll NN = 1e3 + 5;
ll n, bisa = 1, p[NN], x[NN];
std::vector<std::vector<int>> answer;
vector<ll> v[NN];
std::vector<std::vector<int>> px;
ll car(ll pos)
{
if(p[pos] == pos)
return pos;
else
return p[pos] = car(p[pos]);
}
int construct(std::vector<std::vector<int>> pt) {
px = pt;
n = px.size();
for (int i = 0; i < n; i++) {
std::vector<int> row;
row.resize(n, 0);
answer.push_back(row);
}
for (int i = 0; i < n; i++)
p[i] = i;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if(px[i][j])
p[car(i)] = car(j);
for (int i = 0; i < n; i++)
v[car(i)].pb(i);
for (int i = 0; i < n; i++)
{
if(!bisa)
break;
ll sz = v[i].size();
x[0] = 0;
x[1] = 0;
x[2] = 0;
x[3] = 0;
for(ll j = 0; j < sz; j++)
for(ll k = j + 1; k < sz; k++)
x[px[v[i][j]][v[i][k]]] = 1;
if(x[0] + x[1] + x[2] + x[3] == 0)
continue;
else
if(x[0])
bisa = 0;
else
if(x[2] == 1 && x[3] == 1)
bisa = 0;
else
if(x[1] == 1 && x[2] == 0 && x[3] == 0)
{
for(ll j = 1; j < sz; j++)
{
answer[v[i][j - 1]][v[i][j]] = 1;
answer[v[i][j]][v[i][j - 1]] = 1;
}
}
}
if(!bisa)return 0;
build(answer);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
416 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
10 ms |
1408 KB |
Output is correct |
7 |
Correct |
241 ms |
26104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
416 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
10 ms |
1408 KB |
Output is correct |
7 |
Correct |
241 ms |
26104 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
10 ms |
1408 KB |
Output is correct |
13 |
Correct |
237 ms |
26180 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
1024 KB |
Output is correct |
17 |
Correct |
115 ms |
16120 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
60 ms |
6904 KB |
Output is correct |
21 |
Correct |
235 ms |
26104 KB |
Output is correct |
22 |
Correct |
238 ms |
26104 KB |
Output is correct |
23 |
Correct |
246 ms |
26104 KB |
Output is correct |
24 |
Correct |
240 ms |
26108 KB |
Output is correct |
25 |
Correct |
106 ms |
16120 KB |
Output is correct |
26 |
Correct |
102 ms |
16120 KB |
Output is correct |
27 |
Correct |
256 ms |
26104 KB |
Output is correct |
28 |
Correct |
236 ms |
26104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Incorrect |
1 ms |
384 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Too few ways to get from 0 to 1, should be 2 found 0 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
416 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
10 ms |
1408 KB |
Output is correct |
7 |
Correct |
241 ms |
26104 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
10 ms |
1408 KB |
Output is correct |
13 |
Correct |
237 ms |
26180 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
1024 KB |
Output is correct |
17 |
Correct |
115 ms |
16120 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
60 ms |
6904 KB |
Output is correct |
21 |
Correct |
235 ms |
26104 KB |
Output is correct |
22 |
Correct |
238 ms |
26104 KB |
Output is correct |
23 |
Correct |
246 ms |
26104 KB |
Output is correct |
24 |
Correct |
240 ms |
26108 KB |
Output is correct |
25 |
Correct |
106 ms |
16120 KB |
Output is correct |
26 |
Correct |
102 ms |
16120 KB |
Output is correct |
27 |
Correct |
256 ms |
26104 KB |
Output is correct |
28 |
Correct |
236 ms |
26104 KB |
Output is correct |
29 |
Correct |
0 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Incorrect |
1 ms |
384 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
416 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
10 ms |
1408 KB |
Output is correct |
7 |
Correct |
241 ms |
26104 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
10 ms |
1408 KB |
Output is correct |
13 |
Correct |
237 ms |
26180 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
1024 KB |
Output is correct |
17 |
Correct |
115 ms |
16120 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
60 ms |
6904 KB |
Output is correct |
21 |
Correct |
235 ms |
26104 KB |
Output is correct |
22 |
Correct |
238 ms |
26104 KB |
Output is correct |
23 |
Correct |
246 ms |
26104 KB |
Output is correct |
24 |
Correct |
240 ms |
26108 KB |
Output is correct |
25 |
Correct |
106 ms |
16120 KB |
Output is correct |
26 |
Correct |
102 ms |
16120 KB |
Output is correct |
27 |
Correct |
256 ms |
26104 KB |
Output is correct |
28 |
Correct |
236 ms |
26104 KB |
Output is correct |
29 |
Correct |
0 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Incorrect |
1 ms |
384 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |