#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define X first
#define Y second
#define pii pair<int, int>
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
for (; l != r; ++l) cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(args...) abc("[" + string(#args) + "]", args);
#include "grader_B.cpp"
#else
#define test(args...) void(0);
#endif
const int N = 1000000;
vector <pii> edge;
int n, dsu[N];
int Find(int x) {
if (dsu[x] == x)
return x;
return dsu[x] = Find(dsu[x]);
}
void Init(int N) {
n = N;
}
void Link(int a, int b) {
edge.eb(a, b);
}
int check(int x) {
iota(dsu, dsu + n, 0);
vector <int> deg(n, 0);
for (pii e : edge) if (e.X != x && e.Y != x) {
if (Find(e.X) == Find(e.Y))
return false;
dsu[Find(e.X)] = Find(e.Y);
deg[e.X]++, deg[e.Y]++;
}
for (int i = 0; i < n; ++i) if (deg[i] > 2)
return false;
return true;
}
int CountCritical() {
int ans = 0;
for (int i = 0; i < n; ++i) if (check(i)) {
ans++;
}
return ans;
}
/*
7 13
-1
1 2
-1
0 5
-1
2 0
-1
3 2
-1
3 5
-1
4 3
-1
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
202 ms |
460 KB |
Output is correct |
3 |
Correct |
340 ms |
508 KB |
Output is correct |
4 |
Correct |
10 ms |
332 KB |
Output is correct |
5 |
Correct |
105 ms |
420 KB |
Output is correct |
6 |
Correct |
324 ms |
504 KB |
Output is correct |
7 |
Correct |
37 ms |
332 KB |
Output is correct |
8 |
Correct |
175 ms |
436 KB |
Output is correct |
9 |
Correct |
303 ms |
504 KB |
Output is correct |
10 |
Correct |
298 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4088 ms |
15300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
202 ms |
460 KB |
Output is correct |
3 |
Correct |
340 ms |
508 KB |
Output is correct |
4 |
Correct |
10 ms |
332 KB |
Output is correct |
5 |
Correct |
105 ms |
420 KB |
Output is correct |
6 |
Correct |
324 ms |
504 KB |
Output is correct |
7 |
Correct |
37 ms |
332 KB |
Output is correct |
8 |
Correct |
175 ms |
436 KB |
Output is correct |
9 |
Correct |
303 ms |
504 KB |
Output is correct |
10 |
Correct |
298 ms |
460 KB |
Output is correct |
11 |
Execution timed out |
4046 ms |
460 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
202 ms |
460 KB |
Output is correct |
3 |
Correct |
340 ms |
508 KB |
Output is correct |
4 |
Correct |
10 ms |
332 KB |
Output is correct |
5 |
Correct |
105 ms |
420 KB |
Output is correct |
6 |
Correct |
324 ms |
504 KB |
Output is correct |
7 |
Correct |
37 ms |
332 KB |
Output is correct |
8 |
Correct |
175 ms |
436 KB |
Output is correct |
9 |
Correct |
303 ms |
504 KB |
Output is correct |
10 |
Correct |
298 ms |
460 KB |
Output is correct |
11 |
Execution timed out |
4046 ms |
460 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
202 ms |
460 KB |
Output is correct |
3 |
Correct |
340 ms |
508 KB |
Output is correct |
4 |
Correct |
10 ms |
332 KB |
Output is correct |
5 |
Correct |
105 ms |
420 KB |
Output is correct |
6 |
Correct |
324 ms |
504 KB |
Output is correct |
7 |
Correct |
37 ms |
332 KB |
Output is correct |
8 |
Correct |
175 ms |
436 KB |
Output is correct |
9 |
Correct |
303 ms |
504 KB |
Output is correct |
10 |
Correct |
298 ms |
460 KB |
Output is correct |
11 |
Execution timed out |
4088 ms |
15300 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |