제출 #19969

#제출 시각아이디문제언어결과실행 시간메모리
19969tonyjjw흑백 (kriii4_G)C++14
6 / 100
2000 ms1720 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...