#include "supertrees.h"
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f0r(i,n) for(int i = 0; i<n; i++)
#define FOR(i, k, n) for(int i = k; i<n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vb vector<bool>
#define vout(v) for(auto u : v)cout<<u<<' '; cout<<'\n';
#define dout(x) cout<<x<<' '<<#x<<'\n';
using namespace std;
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);
}
build(answer);
*/
vvi ans(n, vi(n));
vb vis(n);
f0r(i, n){
if(!vis[i]){
vi path;
path.pb(i);
vis[i] = 1;
f0r(j, n){
if(p[i][j] == 1 && !vis[j]){
vis[j] = 1;
path.pb(j);
}
}
f0r(j, path.size() - 1){
ans[path[j]][path[j+1]] = 1;
ans[path[j+1]][path[j]] = 1;
}
}
}
f0r(i, n)vis[i] = 0;
f0r(i, n){
if(!vis[i]){
vi cycle;
cycle.pb(i);
vis[i] = 1;
f0r(j, n){
if(p[i][j] == 2 && !vis[j]){
vis[j] = 1;
cycle.pb(j);
}
}
f0r(j, cycle.size() - 1){
ans[cycle[j]][cycle[j+1]] = 1;
ans[cycle[j+1]][cycle[j]] = 1;
}
ans[cycle[0]][cycle[cycle.size() - 1]] = 1;
ans[cycle[cycle.size() - 1]][cycle[0]] = 1;
}
}
build(ans);
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |