이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std ;
//////////////////////////////////////////////////
vector < int > mp[1001] ;
bool ans = true ;
////////////////////////////////////////////////
int construct(std::vector<std::vector<int>> p) {
int n = (int)p.size();
///////////////////////////////////////
for ( int i = 0 ; i < n ; i ++ ){
for ( int j = 0 ; j < n ; j ++ ){
if ( p[i][j] && i != j ){
mp[i].push_back(j) ;
mp[j].push_back(i) ;
}
}
}
for ( int i = 0 ; i < n ; i ++ ){
if ( (int)mp[i].size() == 2 ){
return 0 ;
}
}
//////////////////////////////////////
bool been[1001] = {false} ;
int bridge[n][n] ;
for ( int i = 0 ; i < n ; i ++ ){
for ( int j = 0 ; j < n ; j ++ ){
bridge[i][j] = 0 ;
}
}
for (int i = 0; i < n ; i++ ) {
if ( been[i] ){ continue ; }
int last = -1 ;
for ( int j = i+1 ; j < n ; j ++ ){
if ( p[i][j] ){
been[j] = true ;
last = j ;
for ( int l = j-1 ; l >= i ; l -- ){
if ( p[i][l] ){
bridge[l][j] = 1 ;
bridge[j][l] = 1 ;
break ;
}
}
}
else{
for ( int l = 0 ; l < n ; l ++ ){
if ( p[i][l] && p[l][j] ){
return 0;
}
}
}
}
if ( last != -1 ){
bridge[i][last] = 1 ;
bridge[last][i] = 1 ;
}
}
/////////////////////////////////////
std::vector<std::vector<int>> answer;
for ( int i = 0 ; i < n ; i ++ ){
std::vector < int > row ;
for ( int j = 0 ; j < n ; j ++ ){
row.push_back(bridge[i][j]) ;
}answer.push_back(row) ;
}
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... |