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
using namespace std;
set<int> G[MAXN],a,b;
void initialize(int n)
{
for (int i=0;i<n;i++)
{
for (int j=0;j<n;j++)
{
if (i!=j)
G[i].insert(j);
}
}
}
void DFS(int i,pair<int,int> skipp,set<int> &s)
{
s.insert(i);
for (int next : G[i])
{
if ((i==skipp.first && next==skipp.second) || (i==skipp.second && next==skipp.first))
continue;
if (!s.count(next))
{
s.insert(next);
DFS(next,skipp,s);
}
}
}
bool Check(int u,int v)
{
a.clear();
b.clear();
DFS(u,{u,v},a);
DFS(v,{u,v},b);
for (auto i : a)
{
if (!b.count(i))
return true;
}
}
int hasEdge(int u, int v)
{
if (Check(u,v) || Check(v,u))
return true;
G[u].erase(v);
G[v].erase(u);
return false;
}
Compilation message (stderr)
game.cpp: In function 'bool Check(int, int)':
game.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
41 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |