Submission #17299

# Submission time Handle Problem Language Result Execution time Memory
17299 2015-11-19T07:37:28 Z gs14004 지도 색칠하기 (GA3_map) C++14
Compilation error
0 ms 0 KB
struct disj{
	int pa[42];
	void init(int n){
		for(int i=1; i<=n; i++) pa[i] = i;
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	bool uni(int p, int q){
		p = find(p);
		q = find(q);
		if(p == q) return 0;
		pa[q] = p;
		return 1;
	}
}disj;

long long NumberOfMaps (int N, int M, int *A, int *B){
	long long sum = 0;
	for(int i=0; i<(1<<(N-1)); i++){
		disj.init(2*N);
		bool bad = 0;
		for(int j=0; j<M; j++){
			if(((i >> (A[j] - 1)) & 1) == ((i >> (B[j] - 1)) & 1)){
				disj.uni(A[j], B[j] + n);
				disj.uni(B[j], A[j] + n);
				if(disj.find(A[j]) == disj.find(A[j] + n)){
					bad = 1;
					break;
				}
			}
		}
		if(bad) continue;
		int cnt = 0;
		for(int i=1; i<=2*N; i++){
			if(disj.uni(i, 1)){
				cnt++;
			}
		}
		cnt = (cnt + 1) / 2;
		sum += (2 << cnt);
	}
	return sum;
}

Compilation message

map.cpp: In function ‘long long int NumberOfMaps(int, int, int*, int*)’:
map.cpp:25:27: error: ‘n’ was not declared in this scope
     disj.uni(A[j], B[j] + n);
                           ^