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的代码:
这个题实际不难,就是一个学生每天都会从(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; }
相关文章推荐
- Your ways (动态规划)ACM-ICPC Asia Phuket Regional Programing Contest 2009
- ACM-ICPC Asia Phuket Regional Programing Contest 2009---C:In-circles Again
- ACM-ICPC Asia Phuket Regional Programing Contest 2009----J: Nowhere Money
- UVA 7146 Defeat The Enemy 2014 ACM-ICPC Asia shanghai Regional Contest
- The 36th ACM/ICPC Asia Regional Shanghai Site —— Online Contest(HDU4021-4030)
- HDU 3681 Prison Break 二分+搜索 The 35th ACM-ICPC Asia Regional Contest (Hangzhou)
- hdu 4038 Stone The 36th ACM/ICPC Asia Regional Chengdu Site —— Online Contest
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest - A.Average Score
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest - A
- The 2013 ACM-ICPC Asia Changsha Regional Contest - K
- 2014-2015 ACM-ICPC, Asia Xian Regional Contest C
- The 36th ACM/ICPC Asia Regional Chengdu Site —— Online Contest题解
- The 36th ACM/ICPC Asia Regional Dalian Site —— Online Contest(套题HDU4001-4010)
- hdu 5045 Contest dp+状态压缩 2014 ACM/ICPC Asia Regional Shanghai Online
- 【栈+模拟】The 36th ACM/ICPC Asia Regional Beijing Site Online Contest - B Eliminate Witches!
- The 2011 ACM-ICPC Asia Dalian Regional Contest——D Hexadecimal View
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest - I.Information Entropy
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest - I
- The 2013 ACM-ICPC Asia Changsha Regional Contest(2013区域赛练习)
- HDU - 5045 2014 ACM/ICPC Asia Regional Shanghai Online D - Contest (状压DP)