Submission #19969

# Submission time Handle Problem Language Result Execution time Memory
19969 2016-02-25T07:56:50 Z tonyjjw 흑백 (kriii4_G) C++14
6 / 100
2000 ms 1720 KB
#include <algorithm>
#include <assert.h>
#include <complex>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <limits.h>
#include <locale.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <vector>
#include <unordered_set>
#include <unordered_map>

#pragma warning(disable:4996)
using namespace std;

#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <ldb, ldb> pdd;

int IT_MAX = 131072;
const ll MOD = 1000000007;
const int INF = 1034567891;
const ll LL_INF = 2234567890123456789ll;
const db PI = 3.141592653589793238;
const ldb ERR = 1E-10;

ll mul_inv(ll a, ll b)
{
	ll b0 = b, t, q;
	ll x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

int in[5][5];
int main() {
	int i, j, k, l, m, n, H, W;
	scanf("%d %d", &H, &W);

	ll sum = 0;
	for (i = 0; i < (1 << (H*W)); i++) {
		for (j = 0; j < H*W; j++) {
			k = j / W, l = j%W;
			if (i & (1 << j)) in[k][l] = 1;
			else in[k][l] = 0;
		}

		int c0 = 0, c1 = 0;
		for (k = 1; k < (1 << H); k++) {
			for (l = 1; l < (1 << W); l++) {
				int t = -1;
				for (m = 0; m < H; m++) {
					if (!(k & (1 << m))) continue;
					for (n = 0; n < W; n++) {
						if (!(l & (1 << n))) continue;
						if (t != -1 && t != in[m][n]) break;
						if (t == -1) t = in[m][n];
					}
					if (n < W) break;
				}
				if (m >= H) {
					if (t == 0) c0++;
					else c1++;
				}
			}
		}
		sum += c0*c1;
		sum %= MOD;
	}

	sum = sum * mul_inv(1 << (H*W), MOD) % MOD;
	printf("%lld\n", sum);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1720 KB Output is correct
2 Correct 0 ms 1720 KB Output is correct
3 Correct 0 ms 1720 KB Output is correct
4 Correct 0 ms 1720 KB Output is correct
5 Correct 0 ms 1720 KB Output is correct
6 Correct 0 ms 1720 KB Output is correct
7 Correct 0 ms 1720 KB Output is correct
8 Correct 0 ms 1720 KB Output is correct
9 Correct 0 ms 1720 KB Output is correct
10 Correct 0 ms 1720 KB Output is correct
11 Correct 0 ms 1720 KB Output is correct
12 Correct 7 ms 1720 KB Output is correct
13 Correct 0 ms 1720 KB Output is correct
14 Correct 0 ms 1720 KB Output is correct
15 Correct 9 ms 1720 KB Output is correct
16 Correct 281 ms 1720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2000 ms 1716 KB Program timed out
2 Halted 0 ms 0 KB -