#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> cnt(n, 0);
vector<int> v;
int edges = 0;
for (int i = 0; i < n; i++) {
int deg;
cin >> deg;
cnt[deg]++;
edges += deg;
v.push_back(deg);
while (deg--) {
int x;
cin >> x;
}
}
edges /= 2;
sort(v.rbegin(), v.rend());
int sum = 0;
int ans = 0;
for (int i = 0; i < n - 1; i++) {
sum += v[i] - i;
if (sum == edges) {
if (v[i] == v[i + 1]) {
ans += cnt[v[i]];
} else {
ans++;
}
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
12 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
44 ms |
396 KB |
Output is correct |
3 |
Correct |
202 ms |
404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
376 KB |
Output is correct |
2 |
Correct |
60 ms |
376 KB |
Output is correct |
3 |
Correct |
270 ms |
516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
376 KB |
Output is correct |
2 |
Correct |
136 ms |
9064 KB |
Output is correct |
3 |
Correct |
446 ms |
29612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
5140 KB |
Output is correct |
2 |
Correct |
344 ms |
21012 KB |
Output is correct |
3 |
Correct |
1051 ms |
69756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
707 ms |
47672 KB |
Output is correct |
2 |
Correct |
460 ms |
31236 KB |
Output is correct |
3 |
Correct |
1639 ms |
107724 KB |
Output is correct |
4 |
Correct |
1726 ms |
117332 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |