#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;
endss = 0;
for (int j = 0; j < n; j++)
if (!v[j] && i != j)
dfs(j, i);
ans += (ok && endss == 2);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
24832 KB |
Output is correct |
2 |
Correct |
737 ms |
25084 KB |
Output is correct |
3 |
Correct |
983 ms |
25080 KB |
Output is correct |
4 |
Incorrect |
84 ms |
24824 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4086 ms |
41244 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
24832 KB |
Output is correct |
2 |
Correct |
737 ms |
25084 KB |
Output is correct |
3 |
Correct |
983 ms |
25080 KB |
Output is correct |
4 |
Incorrect |
84 ms |
24824 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
24832 KB |
Output is correct |
2 |
Correct |
737 ms |
25084 KB |
Output is correct |
3 |
Correct |
983 ms |
25080 KB |
Output is correct |
4 |
Incorrect |
84 ms |
24824 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
24832 KB |
Output is correct |
2 |
Correct |
737 ms |
25084 KB |
Output is correct |
3 |
Correct |
983 ms |
25080 KB |
Output is correct |
4 |
Incorrect |
84 ms |
24824 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |