#include "supertrees.h"
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
int construct(std::vector<std::vector<int>> p) {
//subtask 2: star graph, but as connected components
int n = p.size();
vector<vector<int>> ans(n, vector<int> (n));
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
ans[i][j] = 0;
}
}
map<int, vector<int>> cc;
vector<int> flags;
flags.push_back(0);
cc[0].push_back(0);
for(int i=1; i<n; i++){
int tmp = 0;
for(int j: flags){
if(p[i][j]==0) continue;
ans[i][j] = 1;
ans[j][i] = 1;
cc[j].push_back(i);
tmp++;
// break;
}
if(tmp>=2) return 0;
if(tmp==0){
flags.push_back(i);
cc[i].push_back(i);
}
}
// set<pair<int, int>> act;
set<pair<int,int>> act;
for(auto i: cc){
// cout<<"i.first="<<i.first<<"\n";
for(int j: i.second){
for(int k: i.second){
act.insert(make_pair(j, k));
act.insert(make_pair(k, j));
// // cout<<"ABORT";
// if(p[j][k]==0){
// // cout<<"j="<<j<<" k="<<k<<"\n";
// // cout<<"NOPE\n";
// return 0;
// }
}
}
}
// for(auto i: act) cout<<i.first<<" "<<i.second<<"\n";
// cout<<"\n";
// sort(act.begin(), act.end());
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
// cout<<"here";
if(p[i][j]==0){
if(act.count({i,j})==1) return 0;
}
else{
if(act.count({i,j})==0) return 0;
}
}
}
build(ans);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
14 ms |
3164 KB |
Output is correct |
7 |
Correct |
528 ms |
70992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
14 ms |
3164 KB |
Output is correct |
7 |
Correct |
528 ms |
70992 KB |
Output is correct |
8 |
Correct |
1 ms |
348 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 |
5 ms |
1432 KB |
Output is correct |
13 |
Correct |
121 ms |
24148 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
960 KB |
Output is correct |
17 |
Correct |
56 ms |
14212 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
31 ms |
6572 KB |
Output is correct |
21 |
Correct |
145 ms |
28820 KB |
Output is correct |
22 |
Correct |
145 ms |
24144 KB |
Output is correct |
23 |
Correct |
295 ms |
47440 KB |
Output is correct |
24 |
Correct |
161 ms |
24196 KB |
Output is correct |
25 |
Correct |
95 ms |
18808 KB |
Output is correct |
26 |
Correct |
46 ms |
14160 KB |
Output is correct |
27 |
Correct |
351 ms |
47604 KB |
Output is correct |
28 |
Correct |
160 ms |
24188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
428 KB |
Answer gives possible 1 while actual possible 0 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
432 KB |
Too few ways to get from 0 to 1, should be 2 found 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
14 ms |
3164 KB |
Output is correct |
7 |
Correct |
528 ms |
70992 KB |
Output is correct |
8 |
Correct |
1 ms |
348 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 |
5 ms |
1432 KB |
Output is correct |
13 |
Correct |
121 ms |
24148 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
960 KB |
Output is correct |
17 |
Correct |
56 ms |
14212 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
31 ms |
6572 KB |
Output is correct |
21 |
Correct |
145 ms |
28820 KB |
Output is correct |
22 |
Correct |
145 ms |
24144 KB |
Output is correct |
23 |
Correct |
295 ms |
47440 KB |
Output is correct |
24 |
Correct |
161 ms |
24196 KB |
Output is correct |
25 |
Correct |
95 ms |
18808 KB |
Output is correct |
26 |
Correct |
46 ms |
14160 KB |
Output is correct |
27 |
Correct |
351 ms |
47604 KB |
Output is correct |
28 |
Correct |
160 ms |
24188 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
0 ms |
428 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 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 |
14 ms |
3164 KB |
Output is correct |
7 |
Correct |
528 ms |
70992 KB |
Output is correct |
8 |
Correct |
1 ms |
348 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 |
5 ms |
1432 KB |
Output is correct |
13 |
Correct |
121 ms |
24148 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
960 KB |
Output is correct |
17 |
Correct |
56 ms |
14212 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
31 ms |
6572 KB |
Output is correct |
21 |
Correct |
145 ms |
28820 KB |
Output is correct |
22 |
Correct |
145 ms |
24144 KB |
Output is correct |
23 |
Correct |
295 ms |
47440 KB |
Output is correct |
24 |
Correct |
161 ms |
24196 KB |
Output is correct |
25 |
Correct |
95 ms |
18808 KB |
Output is correct |
26 |
Correct |
46 ms |
14160 KB |
Output is correct |
27 |
Correct |
351 ms |
47604 KB |
Output is correct |
28 |
Correct |
160 ms |
24188 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Incorrect |
0 ms |
428 KB |
Answer gives possible 1 while actual possible 0 |
33 |
Halted |
0 ms |
0 KB |
- |