답안 #18992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18992 2016-02-17T02:47:42 Z kriii 흑백 (kriii4_G) C++14
6 / 100
21 ms 1084 KB
#include <stdio.h>

const long long mod = 1000000007;

int h,w,v[10][10];
int bc[32],o[32];

int main()
{
	for (int i=1;i<32;i++){
		int x = i & (-i);
		bc[i] = bc[i-x] + 1;
	}
	scanf ("%d %d",&h,&w);
	long long sum = 0;
	for (int b=0;b<(1<<(h*w));b++){
		for (int i=0;i<h;i++) for (int j=0;j<w;j++) v[i][j] = (b & (1 << (i * w + j))) > 0;
		long long cnt[2] = {0,};
		for (int k=0;k<2;k++){
			o[0] = (1 << w) - 1;
			for (int i=0;i<h;i++){
				o[1<<i] = 0;
				for (int j=0;j<w;j++) if (v[i][j] == k){
					o[1<<i] += 1<<j;
				}
			}
			for (int i=1;i<(1<<h);i++){
				int x = i & (-i);
				if (i != x){
					o[i] = o[i-x] & o[x];
				}
				cnt[k] += (1 << bc[o[i]]) - 1;
			}
		}

		sum += cnt[0] * cnt[1];
		sum %= mod;
	}

	for (int i=0;i<h*w;i++) sum = sum * 500000004 % mod;
	printf ("%lld\n",sum);
	return 0;
}
# 결과 실행 시간 메모리 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 Correct 0 ms 1084 KB Output is correct
6 Correct 0 ms 1084 KB Output is correct
7 Correct 0 ms 1084 KB Output is correct
8 Correct 0 ms 1084 KB Output is correct
9 Correct 0 ms 1084 KB Output is correct
10 Correct 0 ms 1084 KB Output is correct
11 Correct 0 ms 1084 KB Output is correct
12 Correct 1 ms 1084 KB Output is correct
13 Correct 0 ms 1084 KB Output is correct
14 Correct 0 ms 1084 KB Output is correct
15 Correct 0 ms 1084 KB Output is correct
16 Correct 21 ms 1084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1080 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -