# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
800475 | APROHACK | Connecting Supertrees (IOI20_supertrees) | C++17 | 227 ms | 28096 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 ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;
vector<vector<int>>P;
bool vis[1003];
int n;
int construct(std::vector<std::vector<int>> p) {
n = p.size();
P = p;
memset(vis, false, sizeof vis);
vector<std::vector<int>> answer;
vector<int> row;
for(int j = 0 ; j < n ; j ++)row.pb(0);
for (int i = 0; i < n; i++) {
answer.push_back(row);
}
bool isInG[n+1];
memset(isInG, false, sizeof isInG);
for(int i = 0 ; i < n ; i ++){
if(vis[i])continue;
set<int>grupo1;
for(int j = 0 ; j < n ; j ++){
if(p[i][j] == 1){
grupo1.insert(j);
isInG[j] = true;
}
}
vector<int>g;
for(auto j :grupo1){
g.pb(j);
}
for(auto j : g){
for(int x = 0 ; x < n ; x ++){
if(p[j][x] == 1 and !isInG[x])return 0;
if(p[j][x] == 0 and isInG[x])return 0;
}
}
for(auto j : g){
isInG[j] = false;
vis[j] = true;
}
for(int j = 1 ; j < g.size() ; j ++){
answer[g[j-1]][g[j]] = 1;
answer[g[j]][g[j-1]] = 1;
}
}
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... |