답안 #62455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62455 2018-07-28T14:00:16 Z zetapi 낙하산 고리들 (IOI12_rings) C++14
20 / 100
4000 ms 42316 KB
#include <bits/stdc++.h>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=1e6;

vector<int> cur,vec[MAX];

int N,edge,mark[MAX];

void Init(int N_) 
{
  	N=N_;
	for(int A=0;A<N;A++)
	{
		mark[A]=0;
		vec[A].clear();
	}
	return ;
}

void Link(int A,int B) 
{
	//A++;
	//B++;
	vec[A].pb(B);
	vec[B].pb(A);
	return ;
}

void dfs(int node,int br)
{
	cur.pb(node);
	mark[node]=1;
	for(auto A:vec[node])
	{
		if(A==br)
			continue;
		//cout<<"edge between "<<node<<" "<<A<<"\n";
		edge++;
		if(mark[A])
			continue;
		dfs(A,br);
	}
	return ;
}

int ok(int X)
{
	for(auto A:cur)
	{
		if(vec[A].size()==3)
		{
			if(vec[A][0]!=X and vec[A][1]!=X and vec[A][2]!=X)
				return 0;
		}
		else if(vec[A].size()>3)
			return 0;
	}
	return 1;
}

int CountCritical() 
{
	int res=0,l;
	for(int A=0;A<N;A++)
	{
		l=1;
		for(int B=0;B<N;B++)
			mark[B]=0;
		for(int B=0;B<N and l==1;B++)
		{
			if(!mark[B] and (A!=B))
			{
				cur.clear();
				edge=0;
				dfs(B,A);
				if(edge/2>=cur.size())
					l=0;
				else if(!ok(A))
					l=0;
			}
		}
		res+=l;
	}
  	return res;
}

/*signed main()
{
	ios_base::sync_with_stdio(false);

	Init(7);
	cout<<CountCritical()<<"\n";
	Link(1,2);
	cout<<CountCritical()<<"\n";
	Link(0,5);
	cout<<CountCritical()<<"\n";
	Link(2,0);
	cout<<CountCritical()<<"\n";
	Link(3,2);
	cout<<CountCritical()<<"\n";
	Link(3,5);
	cout<<CountCritical()<<"\n";
	Link(4,3);
	cout<<CountCritical()<<"\n";
	return 0;
}*/

Compilation message

rings.cpp: In function 'int CountCritical()':
rings.cpp:84:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(edge/2>=cur.size())
        ~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23800 KB Output is correct
2 Correct 183 ms 24092 KB Output is correct
3 Correct 583 ms 24248 KB Output is correct
4 Correct 30 ms 24248 KB Output is correct
5 Correct 242 ms 24248 KB Output is correct
6 Correct 1109 ms 24328 KB Output is correct
7 Correct 42 ms 24328 KB Output is correct
8 Correct 113 ms 24328 KB Output is correct
9 Correct 522 ms 24328 KB Output is correct
10 Correct 186 ms 24328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4026 ms 42316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23800 KB Output is correct
2 Correct 183 ms 24092 KB Output is correct
3 Correct 583 ms 24248 KB Output is correct
4 Correct 30 ms 24248 KB Output is correct
5 Correct 242 ms 24248 KB Output is correct
6 Correct 1109 ms 24328 KB Output is correct
7 Correct 42 ms 24328 KB Output is correct
8 Correct 113 ms 24328 KB Output is correct
9 Correct 522 ms 24328 KB Output is correct
10 Correct 186 ms 24328 KB Output is correct
11 Execution timed out 4017 ms 42316 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23800 KB Output is correct
2 Correct 183 ms 24092 KB Output is correct
3 Correct 583 ms 24248 KB Output is correct
4 Correct 30 ms 24248 KB Output is correct
5 Correct 242 ms 24248 KB Output is correct
6 Correct 1109 ms 24328 KB Output is correct
7 Correct 42 ms 24328 KB Output is correct
8 Correct 113 ms 24328 KB Output is correct
9 Correct 522 ms 24328 KB Output is correct
10 Correct 186 ms 24328 KB Output is correct
11 Execution timed out 4017 ms 42316 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 23800 KB Output is correct
2 Correct 183 ms 24092 KB Output is correct
3 Correct 583 ms 24248 KB Output is correct
4 Correct 30 ms 24248 KB Output is correct
5 Correct 242 ms 24248 KB Output is correct
6 Correct 1109 ms 24328 KB Output is correct
7 Correct 42 ms 24328 KB Output is correct
8 Correct 113 ms 24328 KB Output is correct
9 Correct 522 ms 24328 KB Output is correct
10 Correct 186 ms 24328 KB Output is correct
11 Execution timed out 4026 ms 42316 KB Time limit exceeded
12 Halted 0 ms 0 KB -