# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447334 | Habib_Assoev | Connecting Supertrees (IOI20_supertrees) | C++14 | 318 ms | 38536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "supertrees.h"
#include<bits/stdc++.h>
#define in freopen ("measurement.in", "r", stdin);
#define out freopen("measurement.out", "w", stdout);
#define ll long long
//#define int long long
#define pf push_front
#define fi first
#define se second
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std ;
long long const N = 1e2 + 7;
long long N1 = 1e9 + 7;
const int MOD = 1e9 + 7;
vector < int > used( 1007 );
vector < int > used1( 1007 );
vector < vector < int > > k( 1007 );
void dfs( int u ){
used[u] = 1;
for( int i = 0 ; i < k[u].size() ; i ++ ){
ll tr = k[u][i];
if( used[tr] == 0 ){
dfs( tr );
}
}
}
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
std::vector<std::vector<int>> answer;
set < int > vc;
int start = -1;
for( int i = 0 ; i < n ; i ++ ){
for( int j = 0 ; j < p[i].size(); j ++ ){
if( p[i][j] == 1 ){
start = i;
k[i].push_back( j );
k[j].push_back( i );
vc.insert( i );
vc.insert( j );
used1[i] = 1;
used1[j] = 1;
}
}
}
dfs( start );
vector < int > v;
for( auto i : vc ){
v.push_back( i );
}
ll a[n][n];
for( int i = 0 ; i < n ; i ++ ){
for( int j = 0 ; j < n ; j ++ ){
a[i][j] = 0;
}
}
for( int i = 1 ; i < v.size(); i ++ ){
a[v[i]][v[i-1]] = 1;
a[v[i-1]][v[i]] = 1;
}
for (int i = 0; i < n; i++) {
std::vector<int> row;
row.resize(n);
for( int j = 0 ; j < n ; j ++ ){
row[j] = a[i][j];
}
answer.push_back(row);
}
ll ch = 0;
for( int i = 0 ; i < n ; i ++ ){
//cout << used[i] << ' ' << used1[i] << endl;
if( used[i] != used1[i] ){
ch = 1;
}
}
vector < int > e;
for( int i = 0 ; i < used.size(); i ++ ){
if( used[i] == 1 ){
e.push_back( i );
}
}
for( int i = 0 ; i < e.size() ; i ++ ){
for( int j = 0 ; j < e.size(); j ++ ){
if( i != j ){
if( p[i][j] == 0 ){
ch = 1;
}
}
}
}
if( ch == 1 ){
return 0;
}else{
build(answer);
return 1;
}
}
Compilation message (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... |