# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441924 | PiejanVDC | Connecting Supertrees (IOI20_supertrees) | C++17 | 1 ms | 292 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>
using namespace std;
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>>v(n,vector<int>(n,0));
for(int i = 0 ; i < n-1 ; i++) {
for(int j = i+1 ; j < n ; j++) {
if(p[i][j]) {
bool ok=true;
stack<pair<int,int>>s;
s.push({i,-1});
while(!s.empty()) {
if(s.top().first == j)
ok=false; break;
for(int k = 0 ; k < n ; k++) {
if(k==s.top().first||k==s.top().second) continue;
if(v[s.top().first][k]) {
s.push({k,s.top().first});
}
}
}
if(ok) {
v[i][j]=1,v[j][i]=1;
}
}
}
}
for(int i = 0 ; i < n ; i++) {
for(int j = i+1 ; j < n ; j++) {
if(!p[i][j]) {
bool ok=true;
stack<pair<int,int>>s;
s.push({i,-1});
while(!s.empty()) {
if(s.top().first == j)
ok=false; break;
for(int k = 0 ; k < n ; k++) {
if(k==s.top().first||k==s.top().second) continue;
if(v[s.top().first][k]) {
s.push({k,s.top().first});
}
}
}
if(!ok) {
return 0;
}
}
}
}
build(v);
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... |