1486 大大走格仔
codeforces
基準時間限制:1 秒 空間限制:131072 kb 分值: 160
難度:6級演算法題
有乙個h行w列的棋盤,裡面有一些格仔是不能走的,現在要求從左上角走到右下角的方案數。
input
單組測試資料。output第一行有三個整數h, w, n(1 ≤ h, w ≤ 10^5, 1 ≤ n ≤ 2000),表示棋盤的行和列,還有不能走的格仔的數目。
接下來n行描述格仔,第i行有兩個整數ri, ci (1 ≤ ri ≤ h, 1 ≤ ci ≤ w),表示格仔所在的行和列。
輸入保證起點和終點不會有不能走的格仔。
輸出答案對1000000007取餘的結果。input示例
3 4 2output示例2 22 3
2
system message
(題目提供者)
c++的執行時限為:1000 ms ,空間限制為:131072 kb
示例及語言說明請按這裡
【分析】
同 bzoj 上學路線,弱化版
【**】
//51nod 1486 大大走格仔
#include#define n 200000
#define ll long long
#define m(a) memset(a,0,sizeof a)
#define fo(i,j,k) for(i=j;i<=k;i++)
using namespace std;
const int mxn=200005;
const int mod=1e9+7;
int n,m,t,ans;
int dp[2005];
int fac[mxn],inv[mxn];
struct point p[2005];
inline bool comp(point u,point v)
{ return u.x==v.x?u.y
51nod 1486 大大走格仔
sol 考慮沒有障礙的情況,從 1,1 到 n,m 答案可直接算出為 可得到遞推式 code include include include include include include include include include include using namespace std typ...
51nod 1486 大大走格仔
1486 大大走格仔 基準時間限制 1 秒 空間限制 131072 kb 有乙個h行w列的棋盤,裡面有一些格仔是不能走的,現在要求從左上角走到右下角的方案數。input 單組測試資料。第一行有三個整數h,w,n 1 h,w 10 5,1 n 2000 表示棋盤的行和列,還有不能走的格仔的數目。接下來...
51Nod 1486 大大走格仔 容斥
題目 對於每個點,求出從起點到它,不經過其他障礙點的方案數 求乙個點時,首先得到走到它的所有方案,減去 x y 都小於它的點的方案 走到該點的方案數 由於該點的方案也不包括其它障礙點,所以就是容斥。如下 include include include include using namespace ...