이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include "supertrees.h"
#define pb push_back
using namespace std;
int n;
vector<vector<int> > a;
int vis[1001], vis2[1001];
vector<int> belong;
int gp[1001], gplwch[1001];
vector<int> gpl;
int fans=1;
vector<int> plamt;
vector<vector<int> > ans;
void dfs(int x)
{
int i;
vis[x]=1, belong.pb(x);
for(i=0;i<n;i++)
if(a[x][i] && !vis[i])
vis[i]=1, dfs(i);
}
void wk2()
{
int i, j;
for(i=0;i<belong.size();i++){
int f=belong[i];
if(!vis2[f]){
vis2[f]=true;
gp[f]=i, gpl.pb(f), gplwch[i]=f;
for(j=0;j<n;j++)
if(a[f][j]==1)
gp[j]=i, vis2[j]=true;
}
}
// circle
if(gpl.size()>=2){
for(i=0;i<gpl.size();i++)
ans[gpl[i]][gpl[(i+1)%gpl.size()]]=ans[gpl[(i+1)%gpl.size()]][gpl[i]]=1;
}
for(i=0;i<belong.size();i++){
int f=belong[i], f2=gp[f];
if(gplwch[f2]!=f)
ans[f][gplwch[f2]]=ans[gplwch[f2]][f]=1;
}
}
void ck()
{
}
void wk()
{
int i;
for(i=0;i<n;i++)
if(!vis[i]){
belong.clear();
dfs(i);
gpl.clear();
wk2();
ck();
}
}
int construct(vector<vector<int> > p)
{
int three=0;
int i, j;
a=p;
n=p.size();
for(i=0;i<n;i++)
plamt.pb(0);
for(i=0;i<n;i++)
ans.pb(plamt);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(a[i][j]==3)
three=1;
if(three) fans=0;
else wk();
if(fans)
build(ans);
return fans;
}
//int main()
//{
// construct({{1, 1, 1}, {1, 1, 1}, {1, 1, 1}});
//
// return 0;
//}
컴파일 시 표준 에러 (stderr) 메시지
supertrees.cpp: In function 'void wk2()':
supertrees.cpp:35:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(i=0;i<belong.size();i++){
| ~^~~~~~~~~~~~~~
supertrees.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(i=0;i<gpl.size();i++)
| ~^~~~~~~~~~~
supertrees.cpp:50:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(i=0;i<belong.size();i++){
| ~^~~~~~~~~~~~~~
# | 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... |