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;
void markall(int i ,int j ,vector<int>&f,vector<int>&b,vector<vector<int>>&p,vector<vector<int>>&answer){
int k = b[i];
while(k!=-1){
int u = j;
while(u!=-1){
if (!answer[k][u]){
p[k][u]--;
p[u][k]--;
answer[k][u]++;
answer[u][k]++;}
u=f[u];}
k=b[k];
}
}
bool check(vector<int>f,vector<int>b,int i ,int j,vector<vector<int>>p){
int k = b[i];
while(k!=-1){
int u = j;
while(u!=-1){
if (p[k][u]<=0)return false;
u=f[u];}
k=b[k];
}
return true;
}
int construct(vector<std::vector<int>> p) {
int n = p.size();
vector<vector<int>>answer(n,vector<int>(n,0));
vector<pair<int,int>>ans;
/*
1 1 0 0 - 0 - 1
1 1 1 0 0 - 1 - 2
1 0 1 1 2 - 3
1 0 1 0
//0 - 1 - 2 - 3 - 4
*/
for (int i =0;i<n;++i){
for (int j =0;j<n;++j){
if (p[i][j]==1){
if (j==i+1||j==i-1)answer[i][j]=1;}
else ans.push_back({i,j});
}
}
for (int i =0;i<ans.size();++i){
answer[0][ans[i].second]=1;
answer[ans[i].first][0]=1;
}
build(answer);
return 1;
}
Compilation message (stderr)
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for (int i =0;i<ans.size();++i){
| ~^~~~~~~~~~~
# | 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... |