이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 2e5+5;
int parent[MAXN],sizee[MAXN];
int find(ll x){
if(x==parent[x])return x;
return parent[x]=find(parent[x]);
}
void unite(ll a, ll b){
a = find(a);
b = find(b);
if(a==b)return;
if(sizee[a]<sizee[b])swap(a,b);
sizee[a]+=sizee[b];
parent[b]=a;
}
int construct(std::vector<std::vector<int>> p) {
int n = p.size(),i,j,k;
std::vector<std::vector<int>> answer;
for (i = 0; i < n; i++) {
std::vector<int> row;
row.resize(n);
answer.push_back(row);
}
for(i=0;i<n;i++){
parent[i]=i;
sizee[i]=1;
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(p[i][j]==0)continue;
unite(i,j);
}
}
vector<vector<int>>meh(n);
for(i=0;i<n;i++){
k=find(i);
meh[k].pb(i);
}//meh[i] e set da componente de i
for(i=0;i<n;i++){
if(i!=find(i))continue;
k = meh[i].size();
for(j=1;j<k;j++){
answer[ meh[i][j] ][ meh[i][j-1] ]=1;
answer[ meh[i][j-1] ][ meh[i][j] ]=1;
}
}
build(answer);
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... |