Submission #17302

# Submission time Handle Problem Language Result Execution time Memory
17302 2015-11-19T11:43:31 Z gs14004 지도 색칠하기 (GA3_map) C++14
Compilation error
0 ms 0 KB
#include <algorithm>
using namespace std;

bool adj[20][20];
int col[20];

int bits;
bool bad;

int dfs(int x, int p){
	if(col[x] && col[x] != p){
		bad = 1;
		return;
	}
	else if(col[x]) return;
	col[x] = p;
	for(int i=0; i<n; i++){
		if(!col[i] && adj[x][i] && (bits >> i) % 2 == (bits >> x) % 2){
			dfs(i);
		}
	}
}
long long NumberOfMaps (int N, int M, int *A, int *B){
	for(int i=0; i<M; i++){
		adj[A[i]][B[i]] = 1;
		adj[B[i]][A[i]] = 1;
	}
	long long sum = 0;
	for(int i=0; i<(1<<(N-1)); i++){
		bits = i;
		bad = 0;
		int cnt = 0;
		for(int i=1; i<=N; i++){
			if(col[i]) continue;
			dfs(i);
			if(bad) break;
			cnt++;
		}
		if(bad) continue;
		sum += (2 << cnt);
	}
	return sum;
}

Compilation message

map.cpp: In function ‘int dfs(int, int)’:
map.cpp:13:3: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
   return;
   ^
map.cpp:15:18: error: return-statement with no value, in function returning ‘int’ [-fpermissive]
  else if(col[x]) return;
                  ^
map.cpp:17:17: error: ‘n’ was not declared in this scope
  for(int i=0; i<n; i++){
                 ^
map.cpp:19:9: error: too few arguments to function ‘int dfs(int, int)’
    dfs(i);
         ^
map.cpp:10:5: note: declared here
 int dfs(int x, int p){
     ^
map.cpp: In function ‘long long int NumberOfMaps(int, int, int*, int*)’:
map.cpp:35:9: error: too few arguments to function ‘int dfs(int, int)’
    dfs(i);
         ^
map.cpp:10:5: note: declared here
 int dfs(int x, int p){
     ^