답안 #119216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
119216 2019-06-20T16:45:10 Z ioilolcom 낙하산 고리들 (IOI12_rings) C++14
0 / 100
4000 ms 98768 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
int N;
vector<int> edges;
const int M=1e6+7;
set<int> adj[M];
int deg[M];
void Init(int N_) {
	N = N_;
}

void Link(int A, int B) {
	adj[A].insert(B);
	adj[B].insert(A);
	deg[A]++;
	deg[B]++;
}
vector<char> color;
bool dfs(int v) {
	color[v] = 1;
	for (int u : adj[v]) {
		if (color[u] == 0) {
			if (dfs(u))
				return true;
		} else if (color[u] == 1) {
			return true;
		}
	}
	color[v] = 2;
	return false;
}

bool cycle() {
	color.assign(N,-1);
	for(int x=0; x<N; x++) {
		if(color[x]) {
			continue;
		}
		if(dfs(x)) {
			return 1;
		}
	}
	return 0;
}

int CountCritical() {
	int ans=0;
	for(int i=0; i<N; i++) {
		vector<int> lol;
		int tmp=deg[i];
		int cnt=0;
		deg[i]=0;
		for(int j=0; j<N; j++) {
			if(adj[i].count(j)) {
				lol.push_back(j);
				adj[j].erase(i);
				adj[i].erase(j);
				deg[j]--;
			}
			if(deg[j]>=3) {
				cnt++;
			}
		}
		deg[i]=tmp;
		for(int v:lol) {
			adj[i].insert(v);
			adj[v].insert(i);
			deg[v]++;
		}
		ans+=((!cnt)&&!cycle());
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 47352 KB Output is correct
2 Correct 92 ms 47736 KB Output is correct
3 Correct 113 ms 47868 KB Output is correct
4 Incorrect 46 ms 47484 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4086 ms 98768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 47352 KB Output is correct
2 Correct 92 ms 47736 KB Output is correct
3 Correct 113 ms 47868 KB Output is correct
4 Incorrect 46 ms 47484 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 47352 KB Output is correct
2 Correct 92 ms 47736 KB Output is correct
3 Correct 113 ms 47868 KB Output is correct
4 Incorrect 46 ms 47484 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 47352 KB Output is correct
2 Correct 92 ms 47736 KB Output is correct
3 Correct 113 ms 47868 KB Output is correct
4 Incorrect 46 ms 47484 KB Output isn't correct
5 Halted 0 ms 0 KB -