이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "supertrees.h"
#define all(a) a.begin(),a.end()
using namespace std;
const int mxn= 1e3+1 ;
vector<int> adj[mxn] , adjj[mxn] , one , mn ;
void dfs(int i , vector<int>& a ){
a[i]=1 ;
for(int& x : adj[i]){
if(a[x]) continue ;
dfs(x,a) ;
}
}
void dfss(int i , vector<int>& a){
a[i] = 1 ;
if(adjj[i].size()==1) one.push_back(i) ;
for(int& x : adjj[i]){
if(a[x]) continue ;
dfss(x,a) ;
}
}
vector<vector<int>> ppp;
bool check(int i , vector<int>& a){
a[i] =1 ;
for(int j=0;j<mn.size();j++){
if(ppp[i][j]==2&&mn[j]!=2) return 1 ;
if(mn[j]==2&&ppp[i][j]!=2) return 1 ;
}
bool b = 0 ;
for(int& x : adj[i]){
if(a[x]) continue ;
b|=check(x,a) ;
}
return b ;
}
int construct(vector<vector<int>> p){
ppp= p ;
int n =p.size() ;
vector<int> the(n) ;
/*for(int i=0;i<n;i++){
bool flg = 0 ;
vector<int> x=p[i] ;
for(int j=0;j<i;j++){
if(x[j]==1){
adj[i].push_back(j) ;
flg = 1 ;
break ;
}
}
if(flg) continue ;
//cout <<i << endl ;
the[i] =1 ;
for(int j=i+1;j<n;j++) if(x[j]==1) adj[i].push_back(j) ;
}
for(int i=0;i<n;i++){
vector<int> vis(n) ;
dfs(i,vis) ;
for(int j=0;j<n;j++){
if(vis[j]==1&&p[i][j]==1) continue ;
if(vis[j]==0&&p[i][j]==0) continue ;
if(p[i][j]==2&&vis[j]==0) continue ;
return 0 ;
}
}*/
for(int i=0;i<n;i++){
//if(the[i]==0) continue ;
for(int j=i-1;j>-1;j--){
// if(the[j]==0) continue ;
if(p[i][j]==2){
adjj[i].push_back(j) ;
break ;
}
}
for(int j=i+1;j<n;j++){
///if(the[j]==0) continue ;
if(p[i][j]==2){
adjj[i].push_back(j) ;
break ;
}
}
}
map<vector<int>,int> pp ;
for(int i=0;i<n;i++){
//if(the[i]==0) continue ;
// if(vis[i]) continue ;
vector<int> vis(n);
one.erase(one.begin(),one.end()) ;
dfss(i,vis) ;
sort(all(one)) ;
for(int j=0;j<n;j++){
if(i==j) continue ;
///if(the[j]==0) continue ;
if(vis[j]==1&&p[i][j]==2) continue ;
if(vis[j]==0&&p[i][j]==0) continue ;
if(vis[j]==0&&p[i][j]==1) continue ;
//cout << i << " " << j << endl ;
return 0 ;
}
if(one.size()==0) continue ;
if(one.size()==1) continue ;
if(one.size()>2) return 0 ;
if(pp[{one[0],one[1]}]) continue ;
pp[{one[0],one[1]}]=1 ;
adjj[one[1]].push_back(one[0]) ;
adjj[one[0]].push_back(one[1]) ;
}
/*vector<int> viss(n) ;
for(int i=0;i<n;i++){
if(viss[i]==1) continue ;
mn = p[i] ;
bool f = check(i,viss) ;
if(f) return 0 ;
}*/
vector<vector<int>> ans ;
for(int i=0;i<n;i++) for(int& x : adjj[i]) adj[i].push_back(x) ;
for(int i=0;i<n;i++){
vector<int> row(n) ;
for(int& x : adj[i]) row[x]= 1 ;
ans.push_back(row) ;
}
build(ans) ;
return 1 ;
}
컴파일 시 표준 에러 (stderr) 메시지
supertrees.cpp: In function 'bool check(int, std::vector<int>&)':
supertrees.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(int j=0;j<mn.size();j++){
| ~^~~~~~~~~~
# | 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... |