1566: [NOI2009]管道取珠 - BZOJ
2015-07-23 00:25
519 查看
Description
View Code
const maxn=550; h=1024523; var f:array[0..1,-1..maxn,-1..maxn]of longint; a,b:array[0..maxn]of char; n,m,xi,yi:longint; function min(x,y:longint):longint; begin if x<y then exit(x); exit(y); end; procedure main; var i,j,l:longint; begin readln(n,m); for i:=1 to n do read(a[i]);readln; for i:=1 to m do read(b[i]); f[0,0,0]:=1;xi:=0;yi:=1; for l:=1 to n+m do begin for i:=0 to min(n,l) do for j:=0 to min(n,l) do begin if a[i]=a[j] then inc(f[yi,i,j],f[xi,i-1,j-1]); if b[l-i]=b[l-j] then inc(f[yi,i,j],f[xi,i,j]); if a[i]=b[l-j] then inc(f[yi,i,j],f[xi,i-1,j]); if b[l-i]=a[j] then inc(f[yi,i,j],f[xi,i,j-1]); f[yi,i,j]:=f[yi,i,j]mod h; end; xi:=xi xor 1;yi:=yi xor 1; fillchar(f[yi],sizeof(f[yi]),0); end; writeln(f[xi,n,n]); end; begin main; end.
View Code
相关文章推荐
- 1564: [NOI2009]二叉查找树 - BZOJ
- 1497: [NOI2006]最大获利 - BZOJ
- 1565: [NOI2009]植物大战僵尸 - BZOJ
- 初学习python,小小尝试
- linux 出行日记(1)
- HTTP 头部
- HDU 1713 相遇周期
- 各种排序算法的复杂度
- extern “C”总结
- hdoj 1082 excel 排序(结构体+sort排序)
- File类学习
- [Android]模拟器无法启动:Waiting for HOME ('android.process.acore') to be launched...
- 设计模式之创建者模式
- UVA 10917 Walk Through the Forest(Dijkstra+DAG动态规划)
- 网络编程socket基本API详解
- PHP中的一些安全配置
- Android 关于shape和selector和layer-list(UI 设计)
- 二叉树题目集
- DuiLib介绍及其消息处理剖析
- [2015-07-22] python007