#include <bits/stdc++.h>
using namespace std;
const int mxN = 1000005;
vector<int> adj[mxN];
int neib[mxN], n;
void Init(int size) {
n = size;
}
void Link(int a, int b) {
adj[a].push_back(b);
adj[b].push_back(a);
neib[a]++, neib[b]++;
}
int CountCritical() {
int ans = 0;
for(int i = 0; i < n; i++) {
for(auto &v : adj[i])
neib[v]--;
bool ok = true;
for(int j = 0; j < n; j++) {
if(neib[j] > 2) {
ok = false;
break;
}
}
for(auto &v : adj[i])
neib[v]++;
if(ok)
ans++;
}
return ans;
}
/*
int main() {
scanf("%d", &n);
Init(n);
int q;
scanf("%d", &q);
while(q--) {
int type, a, b;
scanf("%d", &type);
if(type == 1) {
scanf("%d %d", &a, &b);
Link(a, b);
} else
printf("%d\n", CountCritical());
}
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
23740 KB |
Output is correct |
2 |
Incorrect |
23 ms |
23892 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4051 ms |
48984 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
23740 KB |
Output is correct |
2 |
Incorrect |
23 ms |
23892 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
23740 KB |
Output is correct |
2 |
Incorrect |
23 ms |
23892 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
23740 KB |
Output is correct |
2 |
Incorrect |
23 ms |
23892 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |