#include "supertrees.h"
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
#define ll long long
#define ln '\n'
const int N = 1000 + 5;
int par[N];
int find(int u){return ((u == par[u])? u: par[u]=find(par[u]));}
map<int, vector<int>> mp;
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++) {
std::vector<int> row;
row.resize(n);
answer.push_back(row);
}
iota(par, par+n, 0);
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
if (p[i][j]) par[find(i)] = find(j);
}
}
for (int i = 0; i < n; i++){
for (int j = i+1; j < n; j++){
if (!p[i][j] && find(i) == find(j)) return 0;
}
}
for (int i = 0; i < n; i++){
mp[find(i)].push_back(i);
}
for (auto& [p, v]: mp){
for (auto& u: v){
if (u != p) answer[u][p] = answer[p][u] = 1;
}
}
build(answer);
return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
8 ms |
1104 KB |
Output is correct |
7 |
Correct |
167 ms |
21980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
8 ms |
1104 KB |
Output is correct |
7 |
Correct |
167 ms |
21980 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1252 KB |
Output is correct |
13 |
Correct |
167 ms |
24048 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
804 KB |
Output is correct |
17 |
Correct |
70 ms |
14068 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
6248 KB |
Output is correct |
21 |
Correct |
157 ms |
24004 KB |
Output is correct |
22 |
Correct |
157 ms |
23956 KB |
Output is correct |
23 |
Correct |
162 ms |
24040 KB |
Output is correct |
24 |
Correct |
154 ms |
24064 KB |
Output is correct |
25 |
Correct |
79 ms |
14068 KB |
Output is correct |
26 |
Correct |
65 ms |
14076 KB |
Output is correct |
27 |
Correct |
159 ms |
24008 KB |
Output is correct |
28 |
Correct |
169 ms |
24060 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Too few ways to get from 0 to 1, should be 2 found 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
8 ms |
1104 KB |
Output is correct |
7 |
Correct |
167 ms |
21980 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1252 KB |
Output is correct |
13 |
Correct |
167 ms |
24048 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
804 KB |
Output is correct |
17 |
Correct |
70 ms |
14068 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
6248 KB |
Output is correct |
21 |
Correct |
157 ms |
24004 KB |
Output is correct |
22 |
Correct |
157 ms |
23956 KB |
Output is correct |
23 |
Correct |
162 ms |
24040 KB |
Output is correct |
24 |
Correct |
154 ms |
24064 KB |
Output is correct |
25 |
Correct |
79 ms |
14068 KB |
Output is correct |
26 |
Correct |
65 ms |
14076 KB |
Output is correct |
27 |
Correct |
159 ms |
24008 KB |
Output is correct |
28 |
Correct |
169 ms |
24060 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 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 |
324 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
8 ms |
1104 KB |
Output is correct |
7 |
Correct |
167 ms |
21980 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
7 ms |
1252 KB |
Output is correct |
13 |
Correct |
167 ms |
24048 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
804 KB |
Output is correct |
17 |
Correct |
70 ms |
14068 KB |
Output is correct |
18 |
Correct |
1 ms |
300 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
40 ms |
6248 KB |
Output is correct |
21 |
Correct |
157 ms |
24004 KB |
Output is correct |
22 |
Correct |
157 ms |
23956 KB |
Output is correct |
23 |
Correct |
162 ms |
24040 KB |
Output is correct |
24 |
Correct |
154 ms |
24064 KB |
Output is correct |
25 |
Correct |
79 ms |
14068 KB |
Output is correct |
26 |
Correct |
65 ms |
14076 KB |
Output is correct |
27 |
Correct |
159 ms |
24008 KB |
Output is correct |
28 |
Correct |
169 ms |
24060 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 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 |
- |