# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
733657 |
2023-05-01T07:18:26 Z |
tigar |
Rice Hub (IOI11_ricehub) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
typedef long long ll;
vector<int> jedan[1010], dva[1010];
bool check[1010];
vector<int>lin;
vector<int>cc[1010];
bool provera(int x, std::vector<std::vector<int>>p, int cmp)
{
lin.push_back(x);
cc[cmp].push_back(x);
int n=p.size();
for(int i=0; i<jedan[x].size(); i++)
{
if(check[jedan[x][i]])continue;
check[jedan[x][i]]=true;
for(int j=0; j<n; j++)
{
if(p[jedan[x][i]][j]!=p[x][j])return false;
}
}
for(int i=0; i<dva[x].size(); i++)
{
if(check[dva[x][i]])continue;
check[dva[x][i]]=true;
for(int j=0; j<n; j++)
{
if(p[dva[x][i]][j]!=0 and p[x][j]==0)return false;
if(p[dva[x][i]][j]==0 and p[x][j]!=0)return false;
}
if(!provera(dva[x][i], p, cmp))return false;
}
return true;
}
int construct(std::vector<std::vector<int>>p)
{
int n=p.size();
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
{
if(p[i][j]==1)jedan[i].push_back(j);
else if(p[i][j]==2)dva[i].push_back(j);
else if(p[i][j]==3)return 0;
}
}
int br=1;
for(int i=0; i<n; i++)
{
if(check[i])continue;
if(!provera(i, p, br))return 0;
br++;
}
vector<vector<int> > ans(n);
for(int i=0; i<n; i++){ans[i].resize(n, 0);}
for(int i=0; i<lin.size(); i++)
{
for(int j=1; j<jedan[lin[i]].size(); j++)
{
ans[jedan[lin[i]][j]][jedan[lin[i]][j-1]]=1;
ans[jedan[lin[i]][j-1]][jedan[lin[i]][j]]=1;
}
}
for(int i=1; i<br; i++)
{
for(int j=0; j<cc[i].size(); j++)
{
if(cc[i].size()==2)return 0;
ans[cc[i][j]][(cc[i][j]+1)%cc[i].size()]=1;
ans[(cc[i][j]+1)%cc[i].size()][cc[i][j]]=1;
}
}
for(int i=0; i<n; i++)
{
ans[i][i]=0;
}
build(ans);
return 1;
}
/*int main()
{
int n; cin>>n;
vector<vector<int> >p;
for(int i=0; i<n; i++)
{
vector<int>pp(n);
for(int j=0; j<n; j++)
{
cin>>pp[j];
}
p.push_back(pp);
}
cout<<construct(p);
}*/
Compilation message
ricehub.cpp:2:10: fatal error: supertrees.h: No such file or directory
2 | #include "supertrees.h"
| ^~~~~~~~~~~~~~
compilation terminated.