제출 #62492

#제출 시각아이디문제언어결과실행 시간메모리
62492zetapiParachute rings (IOI12_rings)C++17
컴파일 에러
0 ms0 KiB
#include <cstdio>
#include <vector>
#include <cassert>
 
 
using namespace std;
 
typedef pair<int,int>  pii;
 
const int MAX=1e6+99;
 
vector<int> vec[MAX];

pii E[MAX];

int linear[4],destruct[4],deg[4][MAX],OtherEnd[4][MAX];
 
int N,M,cnt,CycleSize,Quad,a,b,lol,size[MAX];

void Init(int N_) 
{
	M=0;
  	N=N_;
  	cnt=0;
  	Quad=0;
  	CycleSize=0;
  	for(int A=0;A<N;A++)
  	{
  		size[A]=1;
  		deg[0][A]=0;
  		OtherEnd[0][A]=A;
  		vec[A].clear();
  	}
  	return ;
}
 
void Add(int X,int Y)
{
	for(int A=0;A<4;A++) 	
	{
		if(!linear[A] or destruct[A]==X or destruct[A]==Y)
			continue;
		deg[A][X]++;
		deg[A][Y]++;
		if(deg[A][X]==3 or deg[A][Y]==3 or OtherEnd[A][X]==Y)
		{
			linear[A]=0;
			continue;
		}
		a=OtherEnd[A][X];
		b=OtherEnd[A][Y];
		OtherEnd[A][X]=-1;
		OtherEnd[A][Y]=-1;
		OtherEnd[A][a]=b;
		OtherEnd[A][b]=a;
	}
	return ;
}
 
void Split(int X)
{
	Quad=1;
	destruct[0]=X;
	destruct[1]=vec[X][0];
	destruct[2]=vec[X][1];
	destruct[3]=vec[X][2];
	for(int A=0;A<4;A++)
	{
		linear[A]=1;
		for(int B=0;B<N;B++)
		{
			deg[A][B]=0;
			OtherEnd[A][B]=B;
		}
	}
	for(int A=0;A<M;A++)
		Add(E[A].first,E[A].second);
	return ;	
}
 
void Link(int X,int Y) 
{
	E[M++]=make_pair(X,Y);
	if(Quad==0)
	{
		vec[X].push_back(Y);
		vec[Y].push_back(X);
		deg[0][X]++;
		deg[0][Y]++;
		if(deg[0][X]==3)
		{
			Split(X);
			return ;
		}
		if(deg[0][Y]==3)
		{
			Split(Y);
			return ;
		}
		if(OtherEnd[0][X]!=Y)
		{
			lol=size[a];
			size[a]=lol+size[b];
			size[b]=lol+size[b];
			a=OtherEnd[0][X];
			b=OtherEnd[0][Y];
			OtherEnd[0][X]=-1;
			OtherEnd[0][Y]=-1;
			OtherEnd[0][a]=b;
			OtherEnd[0][b]=a;
			return ;
		}
		cnt++;
		if(cnt==1)
			CycleSize=size[Y];
	}
	else
		Add(X,Y);
	return ;
}
 
int CountCritical() 
{	
	if(!Quad)
	{
		if(cnt>1)
			return 0;
		else if(CycleSize)
			return CycleSize;
		else
			return N;
	}
	else
		return (linear[0]+linear[1]+linear[2]+linear[3]);
}

/*int main()
{

}*/

컴파일 시 표준 에러 (stderr) 메시지

rings.cpp: In function 'void Init(int)':
rings.cpp:29:5: error: reference to 'size' is ambiguous
     size[A]=1;
     ^~~~
rings.cpp:18:36: note: candidates are: int size [1000099]
 int N,M,cnt,CycleSize,Quad,a,b,lol,size[MAX];
                                    ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from rings.cpp:2:
/usr/include/c++/7/bits/range_access.h:252:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])
     size(const _Tp (&/*__array*/)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:242:5: note:                 template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)
     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
     ^~~~
rings.cpp: In function 'void Link(int, int)':
rings.cpp:102:8: error: reference to 'size' is ambiguous
    lol=size[a];
        ^~~~
rings.cpp:18:36: note: candidates are: int size [1000099]
 int N,M,cnt,CycleSize,Quad,a,b,lol,size[MAX];
                                    ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from rings.cpp:2:
/usr/include/c++/7/bits/range_access.h:252:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])
     size(const _Tp (&/*__array*/)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:242:5: note:                 template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)
     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
     ^~~~
rings.cpp:103:4: error: reference to 'size' is ambiguous
    size[a]=lol+size[b];
    ^~~~
rings.cpp:18:36: note: candidates are: int size [1000099]
 int N,M,cnt,CycleSize,Quad,a,b,lol,size[MAX];
                                    ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from rings.cpp:2:
/usr/include/c++/7/bits/range_access.h:252:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])
     size(const _Tp (&/*__array*/)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:242:5: note:                 template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)
     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
     ^~~~
rings.cpp:103:16: error: reference to 'size' is ambiguous
    size[a]=lol+size[b];
                ^~~~
rings.cpp:18:36: note: candidates are: int size [1000099]
 int N,M,cnt,CycleSize,Quad,a,b,lol,size[MAX];
                                    ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from rings.cpp:2:
/usr/include/c++/7/bits/range_access.h:252:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])
     size(const _Tp (&/*__array*/)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:242:5: note:                 template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)
     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
     ^~~~
rings.cpp:104:4: error: reference to 'size' is ambiguous
    size[b]=lol+size[b];
    ^~~~
rings.cpp:18:36: note: candidates are: int size [1000099]
 int N,M,cnt,CycleSize,Quad,a,b,lol,size[MAX];
                                    ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from rings.cpp:2:
/usr/include/c++/7/bits/range_access.h:252:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])
     size(const _Tp (&/*__array*/)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:242:5: note:                 template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)
     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
     ^~~~
rings.cpp:104:16: error: reference to 'size' is ambiguous
    size[b]=lol+size[b];
                ^~~~
rings.cpp:18:36: note: candidates are: int size [1000099]
 int N,M,cnt,CycleSize,Quad,a,b,lol,size[MAX];
                                    ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from rings.cpp:2:
/usr/include/c++/7/bits/range_access.h:252:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])
     size(const _Tp (&/*__array*/)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:242:5: note:                 template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)
     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
     ^~~~
rings.cpp:115:14: error: reference to 'size' is ambiguous
    CycleSize=size[Y];
              ^~~~
rings.cpp:18:36: note: candidates are: int size [1000099]
 int N,M,cnt,CycleSize,Quad,a,b,lol,size[MAX];
                                    ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from rings.cpp:2:
/usr/include/c++/7/bits/range_access.h:252:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])
     size(const _Tp (&/*__array*/)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:242:5: note:                 template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)
     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
     ^~~~