记录编号 |
360339 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[HEOI 2015]小Z的房间 |
最终得分 |
100 |
用户昵称 |
sxysxy |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.010 s |
提交时间 |
2016-12-29 13:22:15 |
内存使用 |
0.60 MiB |
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <list>
#include <queue>
#include <vector>
#include <cctype>
#include <algorithm>
using namespace std;
namespace IO
{
char buf[1<<18], *fs, *ft;
inline char readc()
{
return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<18,stdin),fs==ft))?0:*fs++;
}
inline int fast_read()
{
int r;
char c;
bool s = false;
while(c = readc())
{
if(c >= '0' && c <= '9')
{
r = c^0x30;
break;
}else if(c == '-')s = true;
}
while(isdigit(c = readc()))
r = (r<<3)+(r<<1)+(c^0x30);
return s?-r:r;
}
}using IO::fast_read;using IO::readc;
int n, m;
char z[12][12];
void getstr(char *s, int t)
{
char c = readc();
while(isspace(c))c = readc();
s[0] = c;
for(int i = 1; i < t; i++)
s[i] = readc();
}
typedef long long LL;
const LL mod = 1e9;
LL a[90][90], s[12][12], S;
LL gs()
{
S--;
for(int i = 1; i <= S; i++)for(int j = 1; j <= S; j++)
a[i][j] = (a[i][j]+mod)%mod;
LL ans = 1;
for(int j = 1; j <= S; j++)
{
for(int i = j+1; i <= S; i++)
{
while(a[i][j])
{
LL t = a[j][j]/a[i][j];
for(int k = j; k <= S; k++)
{
a[j][k] = ((a[j][k]-t*a[i][k])%mod+mod)%mod;
swap(a[i][k], a[j][k]);
}
ans *= -1;
}
}
ans = ans*a[j][j]%mod;
}
return (ans+mod)%mod;
}
int main()
{
freopen("room.in", "r", stdin);
freopen("room.out", "w", stdout);
n = fast_read(); m = fast_read();
for(int i = 1; i <= n; i++)
getstr(z[i]+1, m);
//外圈补上墙
for(int i = 0; i <= n+1; i++)for(int j = 0; j <= m+1; j++)
if(!i || !j || i==n+1 || j==m+1)z[i][j] = '*';
for(int i = 1; i <= n; i++)for(int j = 1; j <= m; j++)
{
if(z[i][j] == '.')
{
s[i][j] = ++S;
if(z[i-1][j] == '.')a[s[i-1][j]][s[i][j]] = a[s[i][j]][s[i-1][j]] = 1;
if(z[i][j-1] == '.')a[s[i][j-1]][s[i][j]] = a[s[i][j]][s[i][j-1]] = 1;
}
}
for(int i = 1; i <= S; i++)for(int j = 1; j <= S; j++)
if(a[i][j] && i != j)a[i][i]++;
printf("%lld\n", gs());
return 0;
}