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>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=1e5;
vector<int> cur,vec[MAX];
int N,mark[MAX];
void Init(int N_)
{
N=N_;
for(int A=1;A<=N;A++)
{
mark[A]=0;
vec[A].clear();
}
return ;
}
void Link(int A, int B)
{
A++;
B++;
vec[A].pb(B);
vec[B].pb(A);
return ;
}
void dfs(int node,int br)
{
cur.pb(node);
mark[node]=1;
for(auto A:vec[node])
{
if(mark[A] or A==br)
continue;
dfs(A,br);
}
return ;
}
int ok()
{
int co=0,so=0,lo=0,e=0;
for(auto A:cur)
{
e+=vec[A].size();
if(vec[A].size()==1)
co++;
else if(vec[A].size()==2)
so++;
else
lo++;
}
if(e/2>=cur.size())
return 0;
return (co<=2 and lo==0);
}
int CountCritical()
{
int res=0;
for(int A=1;A<=N;A++)
{
for(int B=1;B<=N;B++)
mark[B]=0;
for(int B=1;B<=N;B++)
{
if(!mark[B] and (A!=B))
{
cur.clear();
dfs(B,A);
res+=ok();
}
}
}
return res;
}
/*signed main()
{
ios_base::sync_with_stdio(false);
return 0;
}*/
Compilation message (stderr)
rings.cpp: In function 'int ok()':
rings.cpp:63:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(e/2>=cur.size())
~~~^~~~~~~~~~~~
# | 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... |