Submission #7373

# Submission time Handle Problem Language Result Execution time Memory
7373 2014-08-04T15:31:39 Z gs13068 지도 색칠하기 (GA3_map) C++
Compilation error
0 ms 0 KB
#include<cstdio>

int graph[20][20];
int size[20];
int d[20];
bool vis[20];
int q[20];
int qn;

int main()
{
	long long ans=0,cnt;
	int s,e;
	int i,j,k,l,n,m;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&s,&e);
		graph[s-1][size[s-1]++]=e-1;
		graph[e-1][size[e-1]++]=s-1;
	}
	for(i=0;i<(1<<n-1);i++)
	{
		for(j=0;j<n;j++)vis[j]=false;
		cnt=1;

		for(l=0;l<n;l++)
		{
			if(((1<<l)&i)&&!vis[l])
			{
				qn=0;
				d[l]=0;
				q[qn++]=l;
				vis[l]=true;
				for(j=0;j<qn;j++)
				{
					for(k=0;k<size[q[j]];k++)
					{
						if((1<<graph[q[j]][k])&i)
						{
							if(!vis[graph[q[j]][k]])
							{
								d[graph[q[j]][k]]=1^d[q[j]];
								q[qn++]=graph[q[j]][k];
								vis[graph[q[j]][k]]=true;
							}
							else if(d[graph[q[j]][k]]==d[q[j]])
								break;
						}
					}
					if(k<size[q[j]])break;
				}
				if(j<qn)break;
				cnt<<=1;
			}
		}
		if(l<n)continue;

		for(l=0;l<n;l++)
		{
			if((!((1<<l)&i))&&!vis[l])
			{
				qn=0;
				d[l]=0;
				q[qn++]=l;
				vis[l]=true;
				for(j=0;j<qn;j++)
				{
					for(k=0;k<size[q[j]];k++)
					{
						if(!((1<<graph[q[j]][k])&i))
						{
							if(!vis[graph[q[j]][k]])
							{
								d[graph[q[j]][k]]=1^d[q[j]];
								q[qn++]=graph[q[j]][k];
								vis[graph[q[j]][k]]=true;
							}
							else if(d[graph[q[j]][k]]==d[q[j]])
								break;
						}
					}
					if(k<size[q[j]])break;
				}
				if(j<qn)break;
				cnt<<=1;
			}
		}
		if(l<n)continue;

		ans+=cnt;
	}
	printf("%lld",ans*2);
}

Compilation message

map.cpp: In function 'int main()':
map.cpp:22:18: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
map.cpp:15:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
map.cpp:18:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
/tmp/ccNrNfjn.o: In function `main':
map.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccHyPZBD.o:grader.cpp:(.text.startup+0x0): first defined here
/tmp/ccHyPZBD.o: In function `main':
grader.cpp:(.text.startup+0xe3): undefined reference to `NumberOfMaps(int, int, int*, int*)'
collect2: ld returned 1 exit status