이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |