이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |