#include <bits/stdc++.h>
using namespace std;
const int M = 1e6;
int n, endss;
vector<int> adj[M];
bool v[M], ok;
void dfs(int node, int forb) {
if (!v[node]) {
v[node] = 1;
int cnt = 0;
for (int x : adj[node])
if (x != forb)
cnt++;
if (cnt > 2) {
ok = false;
return;
}
if (!cnt)
endss = 2;
else if (cnt == 1)
endss++;
for (int x : adj[node])
if (x != forb)
dfs(x, forb);
}
}
void Init(int N) { n = N; }
void Link(int a, int b) {
adj[a].push_back(b);
adj[b].push_back(a);
}
int CountCritical() {
int ans = 0;
for (int i = 0; i < n; i++) {
memset(v, 0, sizeof v);
ok = true;
for (int j = 0; j < n; j++)
if (!v[j] && i != j) {
endss = 0;
dfs(j, i);
if (endss != 2)
ok = false;
}
ans += ok;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
24832 KB |
Output is correct |
2 |
Correct |
994 ms |
24960 KB |
Output is correct |
3 |
Correct |
1026 ms |
25060 KB |
Output is correct |
4 |
Correct |
86 ms |
24976 KB |
Output is correct |
5 |
Correct |
427 ms |
25080 KB |
Output is correct |
6 |
Correct |
1118 ms |
25172 KB |
Output is correct |
7 |
Correct |
448 ms |
24832 KB |
Output is correct |
8 |
Correct |
698 ms |
25024 KB |
Output is correct |
9 |
Correct |
1093 ms |
25208 KB |
Output is correct |
10 |
Correct |
1037 ms |
25208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4090 ms |
41204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
24832 KB |
Output is correct |
2 |
Correct |
994 ms |
24960 KB |
Output is correct |
3 |
Correct |
1026 ms |
25060 KB |
Output is correct |
4 |
Correct |
86 ms |
24976 KB |
Output is correct |
5 |
Correct |
427 ms |
25080 KB |
Output is correct |
6 |
Correct |
1118 ms |
25172 KB |
Output is correct |
7 |
Correct |
448 ms |
24832 KB |
Output is correct |
8 |
Correct |
698 ms |
25024 KB |
Output is correct |
9 |
Correct |
1093 ms |
25208 KB |
Output is correct |
10 |
Correct |
1037 ms |
25208 KB |
Output is correct |
11 |
Execution timed out |
4014 ms |
25204 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
24832 KB |
Output is correct |
2 |
Correct |
994 ms |
24960 KB |
Output is correct |
3 |
Correct |
1026 ms |
25060 KB |
Output is correct |
4 |
Correct |
86 ms |
24976 KB |
Output is correct |
5 |
Correct |
427 ms |
25080 KB |
Output is correct |
6 |
Correct |
1118 ms |
25172 KB |
Output is correct |
7 |
Correct |
448 ms |
24832 KB |
Output is correct |
8 |
Correct |
698 ms |
25024 KB |
Output is correct |
9 |
Correct |
1093 ms |
25208 KB |
Output is correct |
10 |
Correct |
1037 ms |
25208 KB |
Output is correct |
11 |
Execution timed out |
4014 ms |
25204 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
24832 KB |
Output is correct |
2 |
Correct |
994 ms |
24960 KB |
Output is correct |
3 |
Correct |
1026 ms |
25060 KB |
Output is correct |
4 |
Correct |
86 ms |
24976 KB |
Output is correct |
5 |
Correct |
427 ms |
25080 KB |
Output is correct |
6 |
Correct |
1118 ms |
25172 KB |
Output is correct |
7 |
Correct |
448 ms |
24832 KB |
Output is correct |
8 |
Correct |
698 ms |
25024 KB |
Output is correct |
9 |
Correct |
1093 ms |
25208 KB |
Output is correct |
10 |
Correct |
1037 ms |
25208 KB |
Output is correct |
11 |
Execution timed out |
4090 ms |
41204 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |