CF559C.Gerald and Giant Chess
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Giant chess is quite common in Geraldion. We will not delve into the rules of the game, we'll just say that the game takes place on an h × w field, and it is painted in two colors, but not like in chess. Almost all cells of the field are white and only some of them are black. Currently Gerald is finishing a game of giant chess against his friend Pollard. Gerald has almost won, and the only thing he needs to win is to bring the pawn from the upper left corner of the board, where it is now standing, to the lower right corner. Gerald is so confident of victory that he became interested, in how many ways can he win?
The pawn, which Gerald has got left can go in two ways: one cell down or one cell to the right. In addition, it can not go to the black cells, otherwise the Gerald still loses. There are no other pawns or pieces left on the field, so that, according to the rules of giant chess Gerald moves his pawn until the game is over, and Pollard is just watching this process.
巨型国际象棋在杰拉尔迪恩非常流行。我们不会深入探讨该游戏的规则,只需说明:游戏在一个 h×w 的棋盘上进行,棋盘被涂成两种颜色,但涂色方式与标准国际象棋不同。棋盘上几乎所有的格子都是白色的,只有少数格子是黑色的。目前,杰拉尔德正与他的朋友波拉德进行一场巨型国际象棋对局,并已接近获胜;他唯一需要做的就是将位于棋盘左上角(即当前位置)的兵移动到右下角,即可获胜。杰拉尔德对胜利如此自信,以至于他开始好奇:他有多少种不同的方式可以获胜?
杰拉尔德所剩的这个兵每次只能朝两个方向之一移动:向下移动一格,或向右移动一格。此外,它不能移动到黑色格子上,否则杰拉尔德仍将输掉比赛。棋盘上已没有其他兵或棋子,因此根据巨型国际象棋的规则,杰拉尔德会持续移动他的兵直至对局结束,而波拉德只是旁观这一过程。
输入格式
The first line of the input contains three integers: h, w, n — the sides of the board and the number of black cells (1 ≤ h, w ≤ 105, 1 ≤ n ≤ 2000).
Next n lines contain the description of black cells. The i-th of these lines contains numbers r__i, c__i (1 ≤ r__i ≤ h, 1 ≤ c__i ≤ w) — the number of the row and column of the i-th cell.
It is guaranteed that the upper left and lower right cell are white and all cells in the description are distinct.
输入的第一行包含三个整数:h、w、n —— 分别表示棋盘的行数、列数以及黑色格子的数量(1≤h,w≤105,1≤n≤2000)。
接下来的 n 行描述了所有黑色格子。其中第 i 行包含两个数 ri、ci(1≤ri≤h,1≤ci≤w),表示第 i 个黑色格子所在的行号与列号。
保证左上角格子和右下角格子均为白色,且所给的所有格子互不相同。
输出格式
Print a single line — the remainder of the number of ways to move Gerald's pawn from the upper left to the lower right corner modulo 109 + 7.
输出一行——从左上角移动 Gerald 的兵到右下角的方案数对 109+7 取模后的余数。
输入输出样例
输入#1
3 4 2 2 2 2 3
输出#1
2
输入#2
100 100 3 15 16 16 15 99 88
输出#2
545732279
输入解题思路,AI测评打分。不知道怎么写?