답안 #18667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18667 2016-02-14T01:28:14 Z suhgyuho_william 낙하산 고리들 (IOI12_rings) C++
20 / 100
4000 ms 40872 KB
#include <vector>

using namespace std;

int N;
vector<int> edge[1000010];

void Init(int N_) {
	N = N_;
}

void Link(int A, int B) {
	A++; B++;
	edge[A].push_back(B);
	edge[B].push_back(A);
}

int j;
bool check[1000010],flag;
void dfs(int x,int par){
	int i,v,cnt = 0;

	check[x] = true;
	for(i=0; i<edge[x].size(); i++){
		v = edge[x][i];
		if(v == par || v == j) continue;
		if(check[v]){ flag = false; continue; }
		dfs(v,x);
		cnt++;
		if(cnt == 2){
			flag = false;
			break;
		}
	}
}

int CountCritical() {
	int i,cnt = 0,t,v;

	for(j=1; j<=N; j++){
		for(i=1; i<=N; i++) check[i] = false;
		flag = true; check[j] = true;
		for(i=1; i<=N; i++){
			if(!check[i]){
				t = 0;
				for(int k=0; k<edge[i].size(); k++){
					v = edge[i][k];
					if(v == j) continue;
					t++;
					if(t == 3){
						flag = false;
						break;
					}
					dfs(v,i);
				}
			}
			if(!flag) break;
		}
		if(flag) cnt++;
	}
	return cnt;
}

Compilation message

rings.cpp: In function 'void dfs(int, int)':
rings.cpp:24:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0; i<edge[x].size(); i++){
           ~^~~~~~~~~~~~~~~
rings.cpp: In function 'int CountCritical()':
rings.cpp:46:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int k=0; k<edge[i].size(); k++){
                  ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23872 KB Output is correct
2 Correct 141 ms 24088 KB Output is correct
3 Correct 89 ms 24136 KB Output is correct
4 Correct 30 ms 24136 KB Output is correct
5 Correct 209 ms 24136 KB Output is correct
6 Correct 945 ms 24420 KB Output is correct
7 Correct 40 ms 24420 KB Output is correct
8 Correct 92 ms 24420 KB Output is correct
9 Correct 505 ms 24420 KB Output is correct
10 Correct 193 ms 24420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4101 ms 40872 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23872 KB Output is correct
2 Correct 141 ms 24088 KB Output is correct
3 Correct 89 ms 24136 KB Output is correct
4 Correct 30 ms 24136 KB Output is correct
5 Correct 209 ms 24136 KB Output is correct
6 Correct 945 ms 24420 KB Output is correct
7 Correct 40 ms 24420 KB Output is correct
8 Correct 92 ms 24420 KB Output is correct
9 Correct 505 ms 24420 KB Output is correct
10 Correct 193 ms 24420 KB Output is correct
11 Execution timed out 4011 ms 40872 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23872 KB Output is correct
2 Correct 141 ms 24088 KB Output is correct
3 Correct 89 ms 24136 KB Output is correct
4 Correct 30 ms 24136 KB Output is correct
5 Correct 209 ms 24136 KB Output is correct
6 Correct 945 ms 24420 KB Output is correct
7 Correct 40 ms 24420 KB Output is correct
8 Correct 92 ms 24420 KB Output is correct
9 Correct 505 ms 24420 KB Output is correct
10 Correct 193 ms 24420 KB Output is correct
11 Execution timed out 4011 ms 40872 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23872 KB Output is correct
2 Correct 141 ms 24088 KB Output is correct
3 Correct 89 ms 24136 KB Output is correct
4 Correct 30 ms 24136 KB Output is correct
5 Correct 209 ms 24136 KB Output is correct
6 Correct 945 ms 24420 KB Output is correct
7 Correct 40 ms 24420 KB Output is correct
8 Correct 92 ms 24420 KB Output is correct
9 Correct 505 ms 24420 KB Output is correct
10 Correct 193 ms 24420 KB Output is correct
11 Execution timed out 4101 ms 40872 KB Time limit exceeded
12 Halted 0 ms 0 KB -