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 <bits/stdc++.h>
#define MAXN 1510
#define inf 1e9
using namespace std;
int edge[MAXN][MAXN],N;
void initialize(int n)
{
N=n;
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
edge[i][j]=-1;
edge[i][i]=1;
}
}
bool Check(int u,int v)
{
vector<int> c;
for (int i=0;i<N;i++)
{
if (edge[u][i] && i!=v)
c.push_back(i);
}
for (int i : c)
{
for (int j=0;j<N;j++)
{
if (j!=u && j!=v && edge[v][j] && edge[j][i])
return false;
}
}
return true;
}
int hasEdge(int u, int v)
{
if (Check(u,v) || Check(v,u) || edge[u][v]==1)
{
for (int i=0;i<N;i++)
{
if (edge[u][i]==1 || edge[v][i]==1)
{
edge[u][i]=1;
edge[v][i]=1;
edge[i][u]=1;
edge[i][v]=1;
}
}
return 1;
}
edge[u][v]=0;
edge[v][u]=0;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |