# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
20050 |
2016-02-25T08:53:37 Z |
xdoju |
흑백 (kriii4_G) |
C++14 |
|
0 ms |
1084 KB |
#include <cstdio>
using namespace std;
const int MOD = 1000000007ll;
int modpow(int r, int n) {
int ret = 1;
while (n > 0) {
if (n % 2 > 0) {
ret = ((long long)ret * r) % MOD;
}
r = ((long long)r * r) % MOD;
n /= 2;
}
return ret;
}
inline int modinv(int n) {
return modpow(n, MOD - 2);
}
inline int modprod(int a, int b) {
a = a % MOD;
b = b % MOD;
return ((long long)a * b) % MOD;
}
inline int modprod(int a, int b, int c) {
c = c % MOD;
return (modprod(a, b) * (long long)c) % MOD;
}
inline int moddiv(int a, int b) {
return ((long long)a * modinv(b)) % MOD;
}
int board[10][10];
int n, m;
bool check(int i, int j, int k, int l, int color) {
for (int l0 = i; l0 <= j; ++l0) {
for (int l1 = k; l1 <= l; ++l1) {
if (board[l0][l1] != color) {
return false;
}
}
}
return true;
}
int ans, allCnt;
void rec(int h, int w) {
if (h == n) {
++allCnt;
int bcnt = 0, wcnt = 0;
for (int i = 0; i < n; ++i) {
for (int j = i; j < n; ++j) {
for (int k = 0; k < m; ++k) {
for (int l = k; l < m; ++l) {
if (board[i][k] == 0) {
bcnt += check(i, j, k, l, board[i][k]) ? 1 : 0;
}
else {
wcnt += check(i, j, k, l, board[i][k]) ? 1 : 0;
}
}
}
}
}
ans = (ans + modprod(bcnt, wcnt)) % MOD;
return;
}
board[h][w] = 0;
if (w == m - 1) {
rec(h + 1, 0);
}
else {
rec(h, w + 1);
}
board[h][w] = 1;
if (w == m - 1) {
rec(h + 1, 0);
}
else {
rec(h, w + 1);
}
}
void proc() {
scanf("%d %d", &n, &m);
ans = 0;
allCnt = 0;
rec(0, 0);
ans = moddiv(ans, allCnt);
printf("%d", ans);
}
int main() {
proc();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Correct |
0 ms |
1084 KB |
Output is correct |
3 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |