#include "supertrees.h"
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = std::pair<ll,ll>;
#define ln "\n"
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define pb emplace_back
#define mp std::make_pair
#define mtp std::make_tuple
#define all(a) a.begin(),a.end()
int construct(std::vector<std::vector<int>> p) {
int N = p.size();
vector<vector<int>> ans(N, vector<int>(N));
vector<bool> flag(N);
auto tree = [&](vi v){
rep(i,1,v.size()){
ans[v[i-1]][v[i]] = ans[v[i]][v[i-1]] = 1;
}
rep(i,0,v.size()){
rep(j,i+1,v.size()){
if(p[v[i]][v[j]] != 1) return true;
}
}
return false;
};
auto loop = [&](vi v){
if(v.size() == 2) return true;
rep(i,0,v.size()){
ans[v[(i+1)%v.size()]][v[i]] = ans[v[i]][v[(i+1)%v.size()]] = 1;
}
rep(i,0,v.size()){
rep(j,i+1,v.size()){
if(p[v[i]][v[j]] != 2) return true;
}
}
return false;
};
rep(i,0,N){
if(flag[i]) continue;
flag[i] = true;
std::queue<ll> que;
que.push(i);
vi v;
while(!que.empty()){
ll now = que.front(); que.pop();
v.pb(now);
rep(next, 0, N){
if(p[now][next]){
if(!flag[next]){
flag[next] = true;
que.push(next);
}
}
}
}
vi cnt(4);
for(auto el: v){
rep(j,0,N){
if(el == j) continue;
cnt[p[el][j]]++;
}
}
if(cnt[2] == 0){
if(tree(v)) return 0;
continue;
}
if(cnt[1] == 0){
if(loop(v)) return 0;
continue;
}
}
build(ans);
return 1;
}
# |
Verdict |
Execution time |
Memory |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
7 ms |
1172 KB |
Output is correct |
7 |
Correct |
151 ms |
21948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
7 ms |
1172 KB |
Output is correct |
7 |
Correct |
151 ms |
21948 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
6 ms |
1108 KB |
Output is correct |
13 |
Correct |
164 ms |
21992 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
4 ms |
800 KB |
Output is correct |
17 |
Correct |
71 ms |
12164 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
46 ms |
5764 KB |
Output is correct |
21 |
Correct |
151 ms |
21964 KB |
Output is correct |
22 |
Correct |
151 ms |
22020 KB |
Output is correct |
23 |
Correct |
154 ms |
22048 KB |
Output is correct |
24 |
Correct |
151 ms |
22032 KB |
Output is correct |
25 |
Correct |
60 ms |
12036 KB |
Output is correct |
26 |
Correct |
60 ms |
12108 KB |
Output is correct |
27 |
Correct |
154 ms |
22020 KB |
Output is correct |
28 |
Correct |
181 ms |
21972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
7 ms |
1304 KB |
Output is correct |
9 |
Correct |
152 ms |
23924 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 |
1212 KB |
Output is correct |
13 |
Correct |
153 ms |
23936 KB |
Output is correct |
14 |
Correct |
0 ms |
300 KB |
Output is correct |
15 |
Correct |
0 ms |
300 KB |
Output is correct |
16 |
Correct |
3 ms |
824 KB |
Output is correct |
17 |
Correct |
71 ms |
14084 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
40 ms |
6260 KB |
Output is correct |
22 |
Correct |
156 ms |
23928 KB |
Output is correct |
23 |
Correct |
152 ms |
23988 KB |
Output is correct |
24 |
Correct |
159 ms |
23936 KB |
Output is correct |
25 |
Correct |
70 ms |
14076 KB |
Output is correct |
26 |
Correct |
70 ms |
14068 KB |
Output is correct |
27 |
Correct |
172 ms |
23936 KB |
Output is correct |
28 |
Correct |
159 ms |
23920 KB |
Output is correct |
29 |
Correct |
68 ms |
14080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
Correct |
38 ms |
6204 KB |
Output is correct |
5 |
Correct |
152 ms |
23956 KB |
Output is correct |
6 |
Correct |
159 ms |
23924 KB |
Output is correct |
7 |
Correct |
157 ms |
23980 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
41 ms |
6328 KB |
Output is correct |
10 |
Correct |
153 ms |
23936 KB |
Output is correct |
11 |
Correct |
190 ms |
23972 KB |
Output is correct |
12 |
Correct |
154 ms |
24012 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Incorrect |
0 ms |
212 KB |
Too few ways to get from 0 to 1, should be 2 found 0 |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
7 ms |
1172 KB |
Output is correct |
7 |
Correct |
151 ms |
21948 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
6 ms |
1108 KB |
Output is correct |
13 |
Correct |
164 ms |
21992 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
4 ms |
800 KB |
Output is correct |
17 |
Correct |
71 ms |
12164 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
46 ms |
5764 KB |
Output is correct |
21 |
Correct |
151 ms |
21964 KB |
Output is correct |
22 |
Correct |
151 ms |
22020 KB |
Output is correct |
23 |
Correct |
154 ms |
22048 KB |
Output is correct |
24 |
Correct |
151 ms |
22032 KB |
Output is correct |
25 |
Correct |
60 ms |
12036 KB |
Output is correct |
26 |
Correct |
60 ms |
12108 KB |
Output is correct |
27 |
Correct |
154 ms |
22020 KB |
Output is correct |
28 |
Correct |
181 ms |
21972 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 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
296 KB |
Output is correct |
34 |
Correct |
1 ms |
300 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
7 ms |
1304 KB |
Output is correct |
37 |
Correct |
152 ms |
23924 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
7 ms |
1212 KB |
Output is correct |
41 |
Correct |
153 ms |
23936 KB |
Output is correct |
42 |
Correct |
0 ms |
300 KB |
Output is correct |
43 |
Correct |
0 ms |
300 KB |
Output is correct |
44 |
Correct |
3 ms |
824 KB |
Output is correct |
45 |
Correct |
71 ms |
14084 KB |
Output is correct |
46 |
Correct |
0 ms |
212 KB |
Output is correct |
47 |
Correct |
0 ms |
212 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
40 ms |
6260 KB |
Output is correct |
50 |
Correct |
156 ms |
23928 KB |
Output is correct |
51 |
Correct |
152 ms |
23988 KB |
Output is correct |
52 |
Correct |
159 ms |
23936 KB |
Output is correct |
53 |
Correct |
70 ms |
14076 KB |
Output is correct |
54 |
Correct |
70 ms |
14068 KB |
Output is correct |
55 |
Correct |
172 ms |
23936 KB |
Output is correct |
56 |
Correct |
159 ms |
23920 KB |
Output is correct |
57 |
Correct |
68 ms |
14080 KB |
Output is correct |
58 |
Incorrect |
0 ms |
212 KB |
Answer gives possible 1 while actual possible 0 |
59 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
7 ms |
1172 KB |
Output is correct |
7 |
Correct |
151 ms |
21948 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 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 |
6 ms |
1108 KB |
Output is correct |
13 |
Correct |
164 ms |
21992 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
4 ms |
800 KB |
Output is correct |
17 |
Correct |
71 ms |
12164 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
46 ms |
5764 KB |
Output is correct |
21 |
Correct |
151 ms |
21964 KB |
Output is correct |
22 |
Correct |
151 ms |
22020 KB |
Output is correct |
23 |
Correct |
154 ms |
22048 KB |
Output is correct |
24 |
Correct |
151 ms |
22032 KB |
Output is correct |
25 |
Correct |
60 ms |
12036 KB |
Output is correct |
26 |
Correct |
60 ms |
12108 KB |
Output is correct |
27 |
Correct |
154 ms |
22020 KB |
Output is correct |
28 |
Correct |
181 ms |
21972 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 |
Correct |
0 ms |
212 KB |
Output is correct |
33 |
Correct |
1 ms |
296 KB |
Output is correct |
34 |
Correct |
1 ms |
300 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
7 ms |
1304 KB |
Output is correct |
37 |
Correct |
152 ms |
23924 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
7 ms |
1212 KB |
Output is correct |
41 |
Correct |
153 ms |
23936 KB |
Output is correct |
42 |
Correct |
0 ms |
300 KB |
Output is correct |
43 |
Correct |
0 ms |
300 KB |
Output is correct |
44 |
Correct |
3 ms |
824 KB |
Output is correct |
45 |
Correct |
71 ms |
14084 KB |
Output is correct |
46 |
Correct |
0 ms |
212 KB |
Output is correct |
47 |
Correct |
0 ms |
212 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
40 ms |
6260 KB |
Output is correct |
50 |
Correct |
156 ms |
23928 KB |
Output is correct |
51 |
Correct |
152 ms |
23988 KB |
Output is correct |
52 |
Correct |
159 ms |
23936 KB |
Output is correct |
53 |
Correct |
70 ms |
14076 KB |
Output is correct |
54 |
Correct |
70 ms |
14068 KB |
Output is correct |
55 |
Correct |
172 ms |
23936 KB |
Output is correct |
56 |
Correct |
159 ms |
23920 KB |
Output is correct |
57 |
Correct |
68 ms |
14080 KB |
Output is correct |
58 |
Correct |
1 ms |
212 KB |
Output is correct |
59 |
Correct |
0 ms |
212 KB |
Output is correct |
60 |
Correct |
0 ms |
212 KB |
Output is correct |
61 |
Correct |
38 ms |
6204 KB |
Output is correct |
62 |
Correct |
152 ms |
23956 KB |
Output is correct |
63 |
Correct |
159 ms |
23924 KB |
Output is correct |
64 |
Correct |
157 ms |
23980 KB |
Output is correct |
65 |
Correct |
0 ms |
212 KB |
Output is correct |
66 |
Correct |
41 ms |
6328 KB |
Output is correct |
67 |
Correct |
153 ms |
23936 KB |
Output is correct |
68 |
Correct |
190 ms |
23972 KB |
Output is correct |
69 |
Correct |
154 ms |
24012 KB |
Output is correct |
70 |
Correct |
1 ms |
212 KB |
Output is correct |
71 |
Correct |
0 ms |
212 KB |
Output is correct |
72 |
Incorrect |
0 ms |
212 KB |
Too few ways to get from 0 to 1, should be 2 found 0 |
73 |
Halted |
0 ms |
0 KB |
- |