Submission #18992

#TimeUsernameProblemLanguageResultExecution timeMemory
18992kriii흑백 (kriii4_G)C++14
6 / 100
21 ms1084 KiB
#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;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...