이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifndef ARTHUR_LOCAL
#include "supertrees.h"
#endif
#ifdef ARTHUR_LOCAL
void build(vector<vector<int>> V)
{
for(auto row:V)
{
for(auto thing:row) cout << thing << " ";
cout << endl;
}
}
#endif
vector<int> comp;
vector<int> adj[1001];
bool vis[1001];
void dfs(int v)
{
vis[v]=1;
comp.push_back(v);
for(auto u:adj[v])
{
if(vis[u]) continue;
dfs(u);
}
}
int construct(vector<vector<int>> P) {
int n = (int)P.size();
vector<vector<int>> answer;
for (int i = 0; i < n; i++)
{
vector<int> row(n);
answer.push_back(row);
}
for(int i=0; i<n; i++)
{
for(int j=i+1; j<n; j++)
{
if(P[i][j]==1)
{
adj[i].push_back(j);
adj[j].push_back(i);
}
}
}
for(int i=0; i<n; i++)
{
comp.clear();
dfs(i);
int m = (int)comp.size();
if(m==1) continue;
// for(au)
for(int i=0; i<m; i++)
{
for(int j=i+1; j<m; j++)
{
if(P[comp[i]][comp[j]]!=2) return 0;
}
}
for(int i=0; i<m; i++)
{
answer[comp[i]][comp[(i+1)%m]]=1;
answer[comp[(i+1)%m]][comp[i]]=1;
}
}
build(answer);
return 1;
}
#ifdef ARTHUR_LOCAL
int main()
{
construct({{1,1,0},{1,1,0},{0,0,1}});
}
#endif
# | 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... |