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;
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(i == j) continue;
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 |
---|
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... |