#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
#define isz(a) ((signed)a.size())
const int N = 1e3 + 5;
int n;
vector <vector <int>> cnt_path;
vector <vector <int>> adj;
bool check_clique(const vector <int>& a, int l, int r){
for (auto u: a){
for (auto v: a){
if (u >= v){
continue;
}
if (not (l <= cnt_path[u][v] and cnt_path[u][v] <= r)){
return false;
}
}
}
return true;
}
vector <bool> vis;
void dfs(int u, int l, int r, vector <int>& a){
vis[u] = true;
a.emplace_back(u);
for (int v = 0; v < n; v++){
if (not vis[v] and l <= cnt_path[u][v] and cnt_path[u][v] <= r){
dfs(v, l, r, a);
}
}
}
vector <bool> is_end;
int construct(vector <vector <int>> _p){
n = isz(_p);
cnt_path = _p;
adj.assign(n, vector <int>(n, 0));
vis.assign(n, false);
is_end.assign(n, false);
for (int u = 0; u < n; u++){
if (vis[u]){
continue;
}
vector <int> a;
dfs(u, 1, 1, a);
if (not check_clique(a, 1, 1)){
return 0;
}
for (int i = 0; i + 1 < isz(a); i++){
int u = a[i], v = a[i + 1];
adj[u][v] = adj[v][u] = 1;
}
is_end[a.back()] = true;
}
vis.assign(n, false);
for (int u = 0; u < n; u++){
if (vis[u]){
continue;
}
vector <int> a;
dfs(u, 1, 2, a);
if (not check_clique(a, 1, 2)){
return 0;
}
vector <int> b;
for (auto u: a){
if (is_end[u]){
b.emplace_back(u);
}
}
if (isz(b) == 1){
continue;
}
for (int i = 0; i < isz(b); i++){
int u = b[i], v = b[(i + 1) % isz(b)];
adj[u][v] = adj[v][u] = 1;
}
}
for (int u = 0; u < n; u++){
for (int v = 0; v < n; v++){
if (cnt_path[u][v] == 3){
return 0;
}
}
}
build(adj);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
8 ms |
1364 KB |
Output is correct |
7 |
Correct |
156 ms |
27980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
8 ms |
1364 KB |
Output is correct |
7 |
Correct |
156 ms |
27980 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 |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1364 KB |
Output is correct |
13 |
Correct |
157 ms |
27852 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 |
71 ms |
18040 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
7176 KB |
Output is correct |
21 |
Correct |
154 ms |
27908 KB |
Output is correct |
22 |
Correct |
164 ms |
27892 KB |
Output is correct |
23 |
Correct |
163 ms |
27892 KB |
Output is correct |
24 |
Correct |
162 ms |
27852 KB |
Output is correct |
25 |
Correct |
70 ms |
18028 KB |
Output is correct |
26 |
Correct |
69 ms |
18032 KB |
Output is correct |
27 |
Correct |
160 ms |
27960 KB |
Output is correct |
28 |
Correct |
154 ms |
27852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
40 ms |
7244 KB |
Output is correct |
5 |
Correct |
158 ms |
27852 KB |
Output is correct |
6 |
Correct |
157 ms |
27944 KB |
Output is correct |
7 |
Correct |
160 ms |
27984 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
40 ms |
7244 KB |
Output is correct |
10 |
Correct |
155 ms |
27924 KB |
Output is correct |
11 |
Correct |
157 ms |
27936 KB |
Output is correct |
12 |
Correct |
158 ms |
27944 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
40 ms |
7244 KB |
Output is correct |
17 |
Correct |
167 ms |
27948 KB |
Output is correct |
18 |
Correct |
155 ms |
27904 KB |
Output is correct |
19 |
Correct |
160 ms |
27888 KB |
Output is correct |
20 |
Correct |
154 ms |
27900 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
8 ms |
1364 KB |
Output is correct |
7 |
Correct |
156 ms |
27980 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 |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1364 KB |
Output is correct |
13 |
Correct |
157 ms |
27852 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 |
71 ms |
18040 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
7176 KB |
Output is correct |
21 |
Correct |
154 ms |
27908 KB |
Output is correct |
22 |
Correct |
164 ms |
27892 KB |
Output is correct |
23 |
Correct |
163 ms |
27892 KB |
Output is correct |
24 |
Correct |
162 ms |
27852 KB |
Output is correct |
25 |
Correct |
70 ms |
18028 KB |
Output is correct |
26 |
Correct |
69 ms |
18032 KB |
Output is correct |
27 |
Correct |
160 ms |
27960 KB |
Output is correct |
28 |
Correct |
154 ms |
27852 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
8 ms |
1364 KB |
Output is correct |
7 |
Correct |
156 ms |
27980 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 |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1364 KB |
Output is correct |
13 |
Correct |
157 ms |
27852 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 |
71 ms |
18040 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
7176 KB |
Output is correct |
21 |
Correct |
154 ms |
27908 KB |
Output is correct |
22 |
Correct |
164 ms |
27892 KB |
Output is correct |
23 |
Correct |
163 ms |
27892 KB |
Output is correct |
24 |
Correct |
162 ms |
27852 KB |
Output is correct |
25 |
Correct |
70 ms |
18028 KB |
Output is correct |
26 |
Correct |
69 ms |
18032 KB |
Output is correct |
27 |
Correct |
160 ms |
27960 KB |
Output is correct |
28 |
Correct |
154 ms |
27852 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |