#include <bits/stdc++.h>
using namespace std;
const int nx=1e6+5;
int n, vs[nx], sm[nx], rem[nx], cnt, res, lvl[nx], t;
vector<int> d[nx];
void dfs(int u, int p)
{
vs[u]=1;
lvl[u]=lvl[p]+1;
for (auto v:d[u])
{
if (v==p) continue;
if (!vs[v]) dfs(v, u);
else if (lvl[v]<lvl[u]) sm[u]++, rem[v]++, cnt++;
}
}
void dfs2(int u, int p)
{
vs[u]=1;
for (auto v:d[u]) if (v!=p&&!vs[v]) dfs2(v, u), sm[u]+=sm[v]-rem[v];
if (sm[u]==cnt)
{
int f=0, tmp=d[u].size()>2;
for (auto v:d[u])
{
if (d[v].size()>3) f=1;
else if (d[v].size()==3) tmp++;
}
if (!f&&tmp==t) res++;
}
}
void Init(int N_) {
n=N_;
}
void Link(int A, int B) {
d[A].push_back(B), d[B].push_back(A);
}
int CountCritical() {
cnt=res=t=0;
for (int i=0; i<n; i++) vs[i]=sm[i]=rem[i]=lvl[i]=0, t+=d[i].size()>2;
for (int i=0; i<n; i++) if (!vs[i]) dfs(i, i);
for (int i=0; i<n; i++) vs[i]=0;
for (int i=0; i<n; i++) if (!vs[i]) dfs2(i, i);
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23896 KB |
Output is correct |
2 |
Correct |
11 ms |
24156 KB |
Output is correct |
3 |
Correct |
11 ms |
24156 KB |
Output is correct |
4 |
Correct |
10 ms |
23900 KB |
Output is correct |
5 |
Correct |
11 ms |
24156 KB |
Output is correct |
6 |
Correct |
11 ms |
24412 KB |
Output is correct |
7 |
Correct |
10 ms |
23896 KB |
Output is correct |
8 |
Correct |
10 ms |
24156 KB |
Output is correct |
9 |
Correct |
11 ms |
24156 KB |
Output is correct |
10 |
Correct |
12 ms |
24156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
314 ms |
53592 KB |
Output is correct |
2 |
Correct |
673 ms |
70228 KB |
Output is correct |
3 |
Correct |
727 ms |
94804 KB |
Output is correct |
4 |
Correct |
917 ms |
82004 KB |
Output is correct |
5 |
Correct |
901 ms |
82768 KB |
Output is correct |
6 |
Correct |
914 ms |
117896 KB |
Output is correct |
7 |
Correct |
748 ms |
93412 KB |
Output is correct |
8 |
Correct |
834 ms |
79544 KB |
Output is correct |
9 |
Correct |
959 ms |
84188 KB |
Output is correct |
10 |
Correct |
787 ms |
86612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23896 KB |
Output is correct |
2 |
Correct |
11 ms |
24156 KB |
Output is correct |
3 |
Correct |
11 ms |
24156 KB |
Output is correct |
4 |
Correct |
10 ms |
23900 KB |
Output is correct |
5 |
Correct |
11 ms |
24156 KB |
Output is correct |
6 |
Correct |
11 ms |
24412 KB |
Output is correct |
7 |
Correct |
10 ms |
23896 KB |
Output is correct |
8 |
Correct |
10 ms |
24156 KB |
Output is correct |
9 |
Correct |
11 ms |
24156 KB |
Output is correct |
10 |
Correct |
12 ms |
24156 KB |
Output is correct |
11 |
Incorrect |
17 ms |
24156 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23896 KB |
Output is correct |
2 |
Correct |
11 ms |
24156 KB |
Output is correct |
3 |
Correct |
11 ms |
24156 KB |
Output is correct |
4 |
Correct |
10 ms |
23900 KB |
Output is correct |
5 |
Correct |
11 ms |
24156 KB |
Output is correct |
6 |
Correct |
11 ms |
24412 KB |
Output is correct |
7 |
Correct |
10 ms |
23896 KB |
Output is correct |
8 |
Correct |
10 ms |
24156 KB |
Output is correct |
9 |
Correct |
11 ms |
24156 KB |
Output is correct |
10 |
Correct |
12 ms |
24156 KB |
Output is correct |
11 |
Incorrect |
17 ms |
24156 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
23896 KB |
Output is correct |
2 |
Correct |
11 ms |
24156 KB |
Output is correct |
3 |
Correct |
11 ms |
24156 KB |
Output is correct |
4 |
Correct |
10 ms |
23900 KB |
Output is correct |
5 |
Correct |
11 ms |
24156 KB |
Output is correct |
6 |
Correct |
11 ms |
24412 KB |
Output is correct |
7 |
Correct |
10 ms |
23896 KB |
Output is correct |
8 |
Correct |
10 ms |
24156 KB |
Output is correct |
9 |
Correct |
11 ms |
24156 KB |
Output is correct |
10 |
Correct |
12 ms |
24156 KB |
Output is correct |
11 |
Correct |
314 ms |
53592 KB |
Output is correct |
12 |
Correct |
673 ms |
70228 KB |
Output is correct |
13 |
Correct |
727 ms |
94804 KB |
Output is correct |
14 |
Correct |
917 ms |
82004 KB |
Output is correct |
15 |
Correct |
901 ms |
82768 KB |
Output is correct |
16 |
Correct |
914 ms |
117896 KB |
Output is correct |
17 |
Correct |
748 ms |
93412 KB |
Output is correct |
18 |
Correct |
834 ms |
79544 KB |
Output is correct |
19 |
Correct |
959 ms |
84188 KB |
Output is correct |
20 |
Correct |
787 ms |
86612 KB |
Output is correct |
21 |
Incorrect |
17 ms |
24156 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |