#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second
using namespace std;
template<typename T, typename Pr = less<T>>
using pq = priority_queue<T, vector<T>, Pr>;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
int n;
void Init(int n_)
{
n = n_;
}
vector<int> edge[1000005];
void Link(int a, int b)
{
edge[a].push_back(b);
edge[b].push_back(a);
}
bool isCritical(int x)
{
vector<int> deg(n);
for (int i = 0; i < n; i++)
{
deg[i] = edge[i].size();
for (auto& e : edge[i])
{
if (e == x)
deg[i]--;
}
}
// 전부 deg 2 이하인지 확인
for (int i = 0; i < n; i++)
{
if (i == x)
continue;
if (deg[i] > 2)
return false;
}
// deg 1에서 시작해서 전부 방문가능한지 확인(chain)
vector<bool> vis(n);
queue<int> q;
for (int i = 0; i < n; i++)
{
if (i == x)
continue;
if (deg[i] == 0)
vis[i] = true;
if (deg[i] != 1)
continue;
q.push(i);
vis[i] = true;
}
while (!q.empty())
{
auto now = q.front();
q.pop();
for (auto& e : edge[now])
{
if (e == x || vis[e])
continue;
vis[e] = true;
q.push(e);
}
}
for (int i = 0; i < n; i++)
{
if (i == x)
continue;
if (!vis[i])
return false;
}
return true;
}
int CountCritical()
{
int ans = 0;
for (int i = 0; i < n; i++)
{
if (isCritical(i))
ans++;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23700 KB |
Output is correct |
2 |
Correct |
68 ms |
23992 KB |
Output is correct |
3 |
Correct |
80 ms |
24156 KB |
Output is correct |
4 |
Correct |
37 ms |
23820 KB |
Output is correct |
5 |
Correct |
210 ms |
24004 KB |
Output is correct |
6 |
Correct |
593 ms |
24076 KB |
Output is correct |
7 |
Correct |
86 ms |
23756 KB |
Output is correct |
8 |
Correct |
166 ms |
23972 KB |
Output is correct |
9 |
Correct |
74 ms |
24028 KB |
Output is correct |
10 |
Correct |
76 ms |
24032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4027 ms |
49004 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23700 KB |
Output is correct |
2 |
Correct |
68 ms |
23992 KB |
Output is correct |
3 |
Correct |
80 ms |
24156 KB |
Output is correct |
4 |
Correct |
37 ms |
23820 KB |
Output is correct |
5 |
Correct |
210 ms |
24004 KB |
Output is correct |
6 |
Correct |
593 ms |
24076 KB |
Output is correct |
7 |
Correct |
86 ms |
23756 KB |
Output is correct |
8 |
Correct |
166 ms |
23972 KB |
Output is correct |
9 |
Correct |
74 ms |
24028 KB |
Output is correct |
10 |
Correct |
76 ms |
24032 KB |
Output is correct |
11 |
Execution timed out |
4048 ms |
24028 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23700 KB |
Output is correct |
2 |
Correct |
68 ms |
23992 KB |
Output is correct |
3 |
Correct |
80 ms |
24156 KB |
Output is correct |
4 |
Correct |
37 ms |
23820 KB |
Output is correct |
5 |
Correct |
210 ms |
24004 KB |
Output is correct |
6 |
Correct |
593 ms |
24076 KB |
Output is correct |
7 |
Correct |
86 ms |
23756 KB |
Output is correct |
8 |
Correct |
166 ms |
23972 KB |
Output is correct |
9 |
Correct |
74 ms |
24028 KB |
Output is correct |
10 |
Correct |
76 ms |
24032 KB |
Output is correct |
11 |
Execution timed out |
4048 ms |
24028 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23700 KB |
Output is correct |
2 |
Correct |
68 ms |
23992 KB |
Output is correct |
3 |
Correct |
80 ms |
24156 KB |
Output is correct |
4 |
Correct |
37 ms |
23820 KB |
Output is correct |
5 |
Correct |
210 ms |
24004 KB |
Output is correct |
6 |
Correct |
593 ms |
24076 KB |
Output is correct |
7 |
Correct |
86 ms |
23756 KB |
Output is correct |
8 |
Correct |
166 ms |
23972 KB |
Output is correct |
9 |
Correct |
74 ms |
24028 KB |
Output is correct |
10 |
Correct |
76 ms |
24032 KB |
Output is correct |
11 |
Execution timed out |
4027 ms |
49004 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |