caioj1497&&bzoj3125: CITY
震惊!bzoj居然又被苏大佬D飞了。。。
这题煞笔模板题好吧。
然而bzojAC caiojWA%40??? 好强啊
今天早上发现是m打成n了囧
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const LL mod=; int n,m,edx,edy;LL ans;
int mp[][];
struct Plug
{
LL f[];
int top;LL sta[],hash[];
void pha(LL s,LL sum)
{
LL x=s%mod;
while(hash[x]!=&&sta[hash[x]]!=s)x=(x+)%mod;
if(hash[x]==)sta[++top]=s,hash[x]=top;
f[hash[x]]+=sum;
}
void clean()
{
top=;
memset(f,,sizeof(f));
memset(hash,,sizeof(hash));
}
}dp[];
LL get_bracket(LL s,LL p)
{
return (s>>(p-)*)&;
}
LL set_bracket(LL s,LL p,LL v)
{
s^=(get_bracket(s,p)<<((p-)*));
s^=(v<<((p-)*));
return s;
}
int pre,now;
void Plug_DP()
{
pre=;now=;
dp[now].clean();dp[now].pha(,);
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
swap(pre,now);dp[now].clean();
for(int k=;k<=dp[pre].top;k++)
{
LL s=dp[pre].sta[k],sum=dp[pre].f[k];
LL p=get_bracket(s,j),q=get_bracket(s,j+);
if(mp[i][j]==)
{
if(p==&&q==)
dp[now].pha(s,sum);
}
else if(mp[i][j]==)
{
if(p==&&q==)
{
if(mp[i+][j]>&&mp[i][j+]>)
{
s=set_bracket(s,j,);
s=set_bracket(s,j+,);
dp[now].pha(s,sum);
}
}
else if(p>&&q==)
{
if(mp[i+][j]>)
{
s=set_bracket(s,j,p);
s=set_bracket(s,j+,);
dp[now].pha(s,sum);
}
if(mp[i][j+]>)
{
s=set_bracket(s,j,);
s=set_bracket(s,j+,p);
dp[now].pha(s,sum);
}
}
else if(p==&&q>)
{
if(mp[i+][j]>)
{
s=set_bracket(s,j,q);
s=set_bracket(s,j+,);
dp[now].pha(s,sum);
}
if(mp[i][j+]>)
{
s=set_bracket(s,j,);
s=set_bracket(s,j+,q);
dp[now].pha(s,sum);
}
}
else if(p==&&q==)
{
if(i==edx&&j==edy)ans+=sum;
}
else if(p==&&q==)
{
s=set_bracket(s,j,);
s=set_bracket(s,j+,);
dp[now].pha(s,sum);
}
else if(p==&&q==)
{
int fd=;
for(int v=j+;v<=m;v++)
{
int bck=get_bracket(s,v);
if(bck==)fd++;
if(bck==)fd--;
if(fd==)
{
s=set_bracket(s,j,);
s=set_bracket(s,j+,);
s=set_bracket(s,v,);
dp[now].pha(s,sum);
break;
}
}
}
else if(p==&&q==)
{
int fd=;
for(int v=j-;v>=;v--)
{
int bck=get_bracket(s,v);
if(bck==)fd++;
if(bck==)fd--;
if(fd==)
{
s=set_bracket(s,j,);
s=set_bracket(s,j+,);
s=set_bracket(s,v,);
dp[now].pha(s,sum);
break;
}
}
}
}
else if(mp[i][j]==)
{
if(p==&&q>)
{
if(mp[i+][j]>)
{
s=set_bracket(s,j,q);
s=set_bracket(s,j+,);
dp[now].pha(s,sum);
}
}
}
else if(mp[i][j]==)
{
if(p>&&q==)
{
if(mp[i][j+]>)
{
s=set_bracket(s,j,);
s=set_bracket(s,j+,p);
dp[now].pha(s,sum);
}
}
}
}
}
for(int k=;k<=dp[now].top;k++)
dp[now].sta[k]<<=;
}
}
char ss[];
int main()
{
scanf("%d%d",&n,&m);
memset(mp,,sizeof(mp));
for(int i=;i<=n;i++)
{
scanf("%s",ss+);
for(int j=;j<=m;j++)
{
if(ss[j]=='.')mp[i][j]=;
else if(ss[j]=='|')mp[i][j]=;
else if(ss[j]=='-')mp[i][j]=;
if(ss[j]!='#')edx=i,edy=j;
}
}
ans=;Plug_DP();
printf("%lld\n",ans);
return ;
}
caioj1497&&bzoj3125: CITY的更多相关文章
- bzoj3125: CITY 题解
3125: CITY Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 486 Solved: 213[Submit][Status][Discuss] ...
- 2019.01.24 bzoj3125: CITY(轮廓线dp)
传送门 题意简述:给一个n∗mn*mn∗m的网格图,有的格子不能走,有的格子只能竖着走,有的格子只能横着走,问用一条回路覆盖所有能走的格子的方案数. 思路: 就是简单的轮廓线dpdpdp加了一点限制而 ...
- 插头dp题表
bzoj1814: Ural 1519 Formula 1 bzoj3125: CITY bzoj1210: [HNOI2004]邮递员 bzoj2331: [SCOI2011]地板 bzoj1187 ...
- 【bzoj3125】CITY 插头dp
题目描述 给出一个n*m的矩阵,某些格子不能通过,某些格子只能上下通过或左右通过.求经过所有非不能通过格子的哈密顿回路条数. 输入 第一行有两个数N, M表示地图被分割成N*M个块,接下来有N行,每行 ...
- BZOJ 2001: [Hnoi2010]City 城市建设
2001: [Hnoi2010]City 城市建设 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 1132 Solved: 555[Submit][ ...
- History lives on in this distinguished Polish city II 2017/1/5
原文 Some fresh air After your time underground,you can return to ground level or maybe even a little ...
- History lives on in this distinguished Polish city 2017/1/4
原文 History lives on in this distinguished Polish city Though it may be ancient. KraKow, Poland, is a ...
- #1094 : Lost in the City
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He does not know where he is ...
- GeoIP Legacy City数据库安装说明
Here is a brief outline of the steps needed to install GeoIP Legacy City on Linux/Unix. The installa ...
随机推荐
- mysql 强制修改密码
mysql忘记密码时强制修改步骤如下: 1.用命令编辑配置文件/etc/my.cnf 2.添加一条语句使其变为不用密码就能进入的状态 skip-grant-tables 3.保存并退出,然后再命令行输 ...
- Python金融量化
Python股票数据分析 最近在学习基于python的股票数据分析,其中主要用到了tushare和seaborn.tushare是一款财经类数据接口包,国内的股票数据还是比较全的 官网地址:http: ...
- webkitdirectory 实现文件夹上传
文件夹上传这个功能在web端可能有需求,这里就简单介绍下用法. 目前只有谷歌浏览器还有Microsoft Edge支持按照文件夹进行上传,具体可以看下百度云盘的网页版的上传按钮,在火狐下就支持按照文件 ...
- vue开发的项目中遇到的警告,报错,配置项目文件等合集(长期更新)
1. Vue组件里面data()里面没有return时触发错误:Vue components Cannot read property '__ob__' of undefined 这个警告不解决会触发 ...
- spring-boot结合mybatis-spring的一个例子
首先spring-boot是用于简化配置的,具有可拔式组件的运用特点. 然后一下是spring-boot结合mybatis-spring的一个例子. 是一个maven项目 demo下载:http:// ...
- C-数据和C
1.常量与变量数据 有些数据在程序使用之前预先设定,并在整个运行过程中没有变化,叫做常量.另外的数据在程序运行过程中可能变化或被赋值,叫做变量. 2.数据类型关键字 对于变量,编译器通过声明语句中指定 ...
- 以SqlHelper为例论面向对象中封装的使用(续)
上文以SqlHelper为例说明了面向对象中封装的好处,但是上文只是简单封装,考虑下面代码的情况: public static Activate GetByCode(string code) { Li ...
- 开发手机APP过程,不同使用场景APP搜索框的样式及区别
搜索框是 app 内最常见的控件之一,可以帮助用户快速又精准找到期望的内容与功能.不同的使用场景下,根据页面中搜索的重要程度,搜索框也有着不同的样式. 下面就常州开发APP公司和大家聊聊常见的四种样式 ...
- tomcat_logs
tomcat logs 目录下各日志文件的含义 参考地址: http://www.cnblogs.com/signheart/p/0ed0bef7dfadf59534eec76ad4607654.ht ...
- 超酷消息警告框插件(SweetAlert)
今天给大家推荐一款不错的超酷消息警告框–SweetAlert:SweetAlert是一款不需要jQuery支持的原生js提示框,风格类似bootstrap.它的提示框不仅美丽动人,并且允许自定义,支持 ...