답안 #116592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116592 2019-06-13T03:27:51 Z faustaadp 낙하산 고리들 (IOI12_rings) C++17
38 / 100
4000 ms 175928 KB
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,isi[1010101],D[1010101],i,j,CC,toe;
vector<ll> v[1010101];
vector<ll> w[1010101];
ll br[1010101],tot;
ll mi[1010101];
ll b[1010101];
ll p[1010101];
ll nw[1010101],te,Z,has;
void Init(int N_) {
  n = N_;
  CC=n;
  isi[0]=n;
  for(i=1;i<=n;i++)p[i]=i;
  memset(b,-1,sizeof(b));
  memset(br,-1,sizeof(br));
}
ll car(ll aa)
{
	if(p[aa]==aa)
		return aa;
	else 
		return p[aa]=car(p[aa]);
}
void dfs(ll aa,ll bb)
{
	te++;
	nw[aa]=te;
	mi[aa]=te;
	b[aa]=toe;
	ll ii;
	for(ii=0;ii<v[aa].size();ii++)
	{
		if(v[aa][ii]==bb)continue;
		if(b[v[aa][ii]]!=toe)
		{
			dfs(v[aa][ii],aa);
			mi[aa]=min(mi[aa],mi[v[aa][ii]]);
		}
		else
			mi[aa]=min(mi[aa],nw[v[aa][ii]]);
		if(mi[v[aa][ii]]>nw[aa])
			br[w[aa][ii]]=toe;
	}
}
void Link(int A, int B) 
{
	Z++;
	v[A].pb(B);
	w[A].pb(Z);
	v[B].pb(A);
	w[B].pb(Z);
	if(p[car(A)]!=car(B))
	{
		p[car(A)]=car(B);
		CC--;
	}
	D[A]++;
	D[B]++;
	isi[D[A]]++;
	isi[D[B]]++;
	isi[D[A]-1]--;
	isi[D[B]-1]--;
	tot+=2;
}
int CountCritical() 
{	
	has=0;
	te=0;
	toe++;
	for(i=0;i<n;i++)
		if(b[i]!=toe)
			dfs(i,i);
	for(i=0;i<n;i++)
	{
		ll CCC=CC,ada=1;
		isi[D[i]]--;
		for(j=0;j<v[i].size();j++)
		{
			if(br[w[i][j]]==toe)
			{
			//	cout<<i<<" "<<v[i][j]<<"_\n";
				CCC++;
			}
			else
				ada=0;
			isi[D[v[i][j]]]--;
			isi[D[v[i][j]]-1]++;
		}
		if(ada)
			CCC--;
		//cout<<(isi[1]+isi[2]*2)<<" "<<tot-D[i]*2<<"\n";
		has+=(((isi[0]+isi[1]+isi[2])==n-1)&&(((n-1)*2-CCC*2)>=(isi[1]+isi[2]*2)));
		isi[D[i]]++;
		for(j=0;j<v[i].size();j++)
		{
			isi[D[v[i][j]]]++;
			isi[D[v[i][j]]-1]--;
		}
	}
	return has;
}

Compilation message

rings.cpp: In function 'void dfs(ll, ll)':
rings.cpp:38:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<v[aa].size();ii++)
           ~~^~~~~~~~~~~~~
rings.cpp: In function 'int CountCritical()':
rings.cpp:84:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<v[i].size();j++)
           ~^~~~~~~~~~~~
rings.cpp:101:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<v[i].size();j++)
           ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 63608 KB Output is correct
2 Correct 62 ms 64120 KB Output is correct
3 Correct 58 ms 64120 KB Output is correct
4 Correct 59 ms 63736 KB Output is correct
5 Correct 59 ms 64120 KB Output is correct
6 Correct 61 ms 64348 KB Output is correct
7 Correct 58 ms 63836 KB Output is correct
8 Correct 62 ms 64120 KB Output is correct
9 Correct 62 ms 64252 KB Output is correct
10 Correct 62 ms 64120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1620 ms 112708 KB Output is correct
2 Correct 3129 ms 139112 KB Output is correct
3 Correct 3660 ms 175928 KB Output is correct
4 Execution timed out 4104 ms 157936 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 63608 KB Output is correct
2 Correct 62 ms 64120 KB Output is correct
3 Correct 58 ms 64120 KB Output is correct
4 Correct 59 ms 63736 KB Output is correct
5 Correct 59 ms 64120 KB Output is correct
6 Correct 61 ms 64348 KB Output is correct
7 Correct 58 ms 63836 KB Output is correct
8 Correct 62 ms 64120 KB Output is correct
9 Correct 62 ms 64252 KB Output is correct
10 Correct 62 ms 64120 KB Output is correct
11 Correct 70 ms 64248 KB Output is correct
12 Correct 127 ms 64944 KB Output is correct
13 Correct 116 ms 65016 KB Output is correct
14 Correct 99 ms 64604 KB Output is correct
15 Correct 111 ms 64888 KB Output is correct
16 Correct 123 ms 64760 KB Output is correct
17 Correct 129 ms 64836 KB Output is correct
18 Correct 142 ms 65272 KB Output is correct
19 Correct 119 ms 64964 KB Output is correct
20 Correct 118 ms 64780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 63608 KB Output is correct
2 Correct 62 ms 64120 KB Output is correct
3 Correct 58 ms 64120 KB Output is correct
4 Correct 59 ms 63736 KB Output is correct
5 Correct 59 ms 64120 KB Output is correct
6 Correct 61 ms 64348 KB Output is correct
7 Correct 58 ms 63836 KB Output is correct
8 Correct 62 ms 64120 KB Output is correct
9 Correct 62 ms 64252 KB Output is correct
10 Correct 62 ms 64120 KB Output is correct
11 Correct 70 ms 64248 KB Output is correct
12 Correct 127 ms 64944 KB Output is correct
13 Correct 116 ms 65016 KB Output is correct
14 Correct 99 ms 64604 KB Output is correct
15 Correct 111 ms 64888 KB Output is correct
16 Correct 123 ms 64760 KB Output is correct
17 Correct 129 ms 64836 KB Output is correct
18 Correct 142 ms 65272 KB Output is correct
19 Correct 119 ms 64964 KB Output is correct
20 Correct 118 ms 64780 KB Output is correct
21 Execution timed out 4088 ms 66140 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 63608 KB Output is correct
2 Correct 62 ms 64120 KB Output is correct
3 Correct 58 ms 64120 KB Output is correct
4 Correct 59 ms 63736 KB Output is correct
5 Correct 59 ms 64120 KB Output is correct
6 Correct 61 ms 64348 KB Output is correct
7 Correct 58 ms 63836 KB Output is correct
8 Correct 62 ms 64120 KB Output is correct
9 Correct 62 ms 64252 KB Output is correct
10 Correct 62 ms 64120 KB Output is correct
11 Correct 1620 ms 112708 KB Output is correct
12 Correct 3129 ms 139112 KB Output is correct
13 Correct 3660 ms 175928 KB Output is correct
14 Execution timed out 4104 ms 157936 KB Time limit exceeded
15 Halted 0 ms 0 KB -