답안 #526582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526582 2022-02-15T10:41:46 Z jwvg0425 낙하산 고리들 (IOI12_rings) C++17
0 / 100
1220 ms 101844 KB
#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];
int order[1000005];
int t = 0;
int comp[1000005];
int par[1000005];
int up[1000005];
vector<int> s;

void Link(int a, int b)
{
	edge[a].push_back(b);
	edge[b].push_back(a);
}

void dfs(int x)
{
	s.push_back(x);
	t++;
	order[x] = t;
	up[x] = order[x];
	comp[x] = s.size() == 1 ? 0 : 1;

	for (auto& e : edge[x])
	{
		if (order[e] == 0)
		{
			par[e] = x;
			dfs(e);

			if (up[e] >= order[x])
				comp[x]++;
		}

		if (e != par[x])
			up[x] = min(up[x], up[e]);
	}
}

int getDegree(int x, int off = 0)
{
	return min((int)edge[x].size() - off, 3);
}

int solve(int x)
{
	s.clear();
	dfs(x);

	vector<int> cnt(6);

	for (auto& si : s)
		cnt[getDegree(si)]++;

	if (cnt[3] == 0)
		return 0;

	int res = 0;

	for (auto& si : s)
	{
		cnt[getDegree(si)]--;
		for (auto& e : edge[si])
		{
			cnt[getDegree(e)]--;
			cnt[getDegree(e, 1)]++;
		}

		if (comp[si] * 2 == cnt[1] + cnt[0] * 2 && cnt[3] == 0)
			res++;

		for (auto& e : edge[si])
		{
			cnt[getDegree(e)]++;
			cnt[getDegree(e, 1)]--;
		}
		cnt[getDegree(si)]++;
	}

	return res;
}

int CountCritical()
{
	for (int i = 0; i < n; i++)
	{
		order[i] = comp[i] = 0;
		par[i] = -1;
		up[i] = 987654321;
	}

	t = 0;

	vector<int> cx;
	int res = 0;
	for (int i = 0; i < n && cx.size() < 2; i++)
	{
		if (order[i] != 0)
			continue;

		int now = solve(i);

		if (now == 0)
		{
			res += s.size();
			continue;
		}

		cx.push_back(now);
	}

	if (cx.size() >= 2)
		return 0;

	if (cx.empty())
		return res;

	return cx[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 24076 KB Output is correct
3 Correct 14 ms 24088 KB Output is correct
4 Incorrect 13 ms 23876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 390 ms 55164 KB Output is correct
2 Correct 801 ms 72780 KB Output is correct
3 Correct 1220 ms 101844 KB Output is correct
4 Incorrect 1052 ms 84916 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 24076 KB Output is correct
3 Correct 14 ms 24088 KB Output is correct
4 Incorrect 13 ms 23876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 24076 KB Output is correct
3 Correct 14 ms 24088 KB Output is correct
4 Incorrect 13 ms 23876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 24076 KB Output is correct
3 Correct 14 ms 24088 KB Output is correct
4 Incorrect 13 ms 23876 KB Output isn't correct
5 Halted 0 ms 0 KB -