Submission #17305

# Submission time Handle Problem Language Result Execution time Memory
17305 2015-11-19T11:44:41 Z gs14004 지도 색칠하기 (GA3_map) C++14
0 / 120
585 ms 1084 KB
#include <algorithm>
using namespace std;

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

int bits, n;
bool bad;

void 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, 3-p);
		}
	}
}
long long NumberOfMaps (int N, int M, int *A, int *B){
	n = N;
	for(int i=0; i<M; i++){
		adj[A[i]-1][B[i]-1] = 1;
		adj[B[i]-1][A[i]-1] = 1;
	}
	long long sum = 0;
	for(int i=0; i<(1<<(N-1)); i++){
		fill(col, col + N, 0);
		bits = i;
		bad = 0;
		int cnt = 0;
		for(int i=0; i<N; i++){
			if(col[i]) continue;
			dfs(i, 1);
			if(bad) break;
			cnt++;
		}
		if(bad) continue;
		sum += (2 << cnt);
	}
	return sum;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Incorrect 0 ms 1084 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 0 ms 1084 KB Output is correct
4 Correct 0 ms 1084 KB Output is correct
5 Incorrect 0 ms 1084 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1084 KB Output is correct
2 Correct 0 ms 1084 KB Output is correct
3 Correct 2 ms 1084 KB Output is correct
4 Correct 2 ms 1084 KB Output is correct
5 Correct 5 ms 1084 KB Output is correct
6 Incorrect 8 ms 1084 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1084 KB Output is correct
2 Correct 64 ms 1084 KB Output is correct
3 Correct 27 ms 1084 KB Output is correct
4 Correct 27 ms 1084 KB Output is correct
5 Correct 64 ms 1084 KB Output is correct
6 Incorrect 47 ms 1084 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 420 ms 1084 KB Output is correct
2 Correct 377 ms 1084 KB Output is correct
3 Correct 380 ms 1084 KB Output is correct
4 Correct 359 ms 1084 KB Output is correct
5 Correct 445 ms 1084 KB Output is correct
6 Incorrect 585 ms 1084 KB Output isn't correct
7 Halted 0 ms 0 KB -