dp - Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess

时间:2021-05-30 23:23:56

Gerald and Giant Chess

Problem's Link: http://codeforces.com/contest/559/problem/C


Mean:

一个n*m的网格,让你从左上角走到右下角,有一些点不能经过,问你有多少种方法。

analyse:

BZOJ上的原题。

首先把坏点和终点以x坐标为第一键值,y坐标为第二键值排序 。

令fi表示从原点不经过任何坏点走到第i个点的个数,那么有DP方程:

  fi=Cxixi+yi−∑(xj<=xi,yj<=yi)C(xi−xj)(xi−xj)+(yi−yj)∗fj

当于枚举第一个遇到的坏点是啥,然后从总方案里减掉。

然后再利用组合数取模就行。

(http://blog.csdn.net/popoqqq/article/details/46121519)

Time complexity: O(N*N)

Source code: 

;
;
      );
           ; ; ;
     ;
      );
     ; );
     ; ; ) ; ; ;
}