您的位置:首页 > 其它

ACM-ICPC Asia Phuket Regional Programing Contest 2009----F: Your Ways

2010-09-02 00:10 369 查看
题目链接:http://acm.bnu.edu.cn/contest/problem_show.php?pid=4275

这个题实际不难,就是一个学生每天都会从(0,0)到(w,h),每天都会有一些道路不能走,求每天从起点到终点的种数,但比赛时却少有人去碰,原因是忽略了题目中最重要的一句话“The blocking is done in such a way that it is not possible to reach parts of the streets or avenues which is blocked from some other part which is blocked as well through any paths containing only West-to-East and South-to-North walks.”这对降低难度起到了至关重要的作用,意思是说每条道不能走的道路不会相互影响,赛后大家一起讨论时才发现了这一点.....- -||这道晃人的体就完全可在

600 Bytes之内解决了!

rookie的代码:

#include<stdio.h>
#define mod 2552
int t,w,h,k,aa,b,c,d,ans,num;
int a[1010][1010];
int main()
{

scanf("%d",&t);
while(t--){
scanf("%d%d%d",&w,&h,&k);
for(int i=0;i<=(w>h?w:h);i++)
a[0][i]=a[i][0]=1;
for(int i=1;i<=h;i++)
for(int j=1;j<=w;j++)
a[i][j]=(a[i][j-1]+a[i-1][j])%mod;
for(int i=1;i<=k;i++){
ans=a[h][w];
scanf("%d",&num);
for(int i=1;i<=num;i++){
scanf("%d%d%d%d",&aa,&b,&c,&d);
ans-=a[b][aa]*a[h-d][w-c];
ans=(ans+mod)%mod;
}
if(ans<0)ans+=mod;
printf("%d/n",ans);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: