# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
519155 | LucaIlie | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 1 ms | 276 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include "supertrees.h"
#define MAX_N 1000
using namespace std;
struct dsu {
int n;
int sef[MAX_N];
void init( int x ) {
int i;
n = x;
for ( i = 0; i < n; i++ )
sef[i] = i;
}
int find( int x ) {
if ( sef[x] != x )
sef[x] = find( sef[x] );
return sef[x];
}
void unionn( int x, int y ) {
x = find( x );
y = find( y );
sef[y] = x;
}
};
int construct( vector <vector <int>> p ) {
int n, a, x, y, i, j;
dsu forest;
vector <int> f[MAX_N];
n = p.size();
vector <vector <int>> b( n );
forest.init( n );
for ( x = 0; x < n; x++ ) {
for ( y = 0; y < n; y++ ) {
if ( p[x][y] > 0 )
forest.unionn( x, y );
}
}
for ( x = 0; x < n; x++ )
f[forest.find( x )].push_back( x );
for ( i = 0; i < n; i++ ) {
for ( j = 0; j < n; j++ )
b[i].push_back( 0 );
}
for ( x = 0; x < n; x++ ) {
if ( f[x].size() ) {
a = p[f[x][0]][f[x][0]];
for ( i = 0; i < f[x].size(); i++ ) {
for ( j = 0; j < f[x].size(); j++ ) {
if ( a != p[f[x][i]][f[x][j]] )
return 0;
}
}
for ( i = 0; i < f[x].size() - 1; i++ ) {
b[f[x][i]][f[x][i + 1]] = 1;
b[f[x][i + 1]][f[x][i]] = 1;
}
if ( f[x].size() < a )
return 0;
b[f[x][0]][f[x][a]] = 1;
b[f[x][a]][f[x][0]] = 1;
}
}
build( b );
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |