当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5068:Harry And Math Teacher

题目描述
As we all know, Harry Porter learns magic at Hogwarts School. However, learning magical knowledge alone is insufficient to become a great magician. Sometimes, Harry also has to gain knowledge from other certain subjects, such as language, mathematics, English, and even algorithm.
In Hogwarts, there is a tall castle in which all teachers live. The castle is rather special. In every floor there are two doors, behind each of them there existing two stairs to the next floor’s two doors. And if you are at the i-th floor’s j-th door , then you can just go to the next floor from this door. However, something even more interesting (or we can say "magic") can happen to the stairs: sometimes they break into pieces (making it impossible to go to the next floor), and sometimes the fragments can joint together and become the whole stair again. Now suppose Harry is in the a-th floor (you know, Harry is the hero, so he lives in the teachers’ building somehow), and his math teacher b-th floor. Sometimes the math teacher will call Harry to his room. Facing these magic stairs, Harry gets puzzled how he can go to see the math teacher. Can you help Harry figure out how many ways exactly he can choose without going backwards? You can assume that the change of the stairs will not happen when Harry is on his way. Harry can begin at any doors in floor a and he can end at any doors in floor b. And as Harry want to arrive as soon as possible, so he can not go back to the past. And at the beginning all the stairs are intact. And the answer may be too large, you should output the answer mod 1000000007.
输入解释
They are sever test cases, you should process to the end of file.
For each test case, there are two integers n and $m(2 \leq n \leq 50000, 1 \leq m \leq 50000)$ in the first line, indicate the number of the castle’s layers and the number of queries. And the following m lines, each line contains three or four integers. If the first integer op equals 0, there are two integers a and b ($1 \leq a < b \leq n$) follow, indicate the position of Harry and math teacher. Otherwise, there are three integers $x, y, z (1 \leq x < n, 1 \leq y, z \leq 2)$follow, it means that the stair between the $x_{th}$ floor’s $y_{th}$ door and the $(x+1)_{th}$ floor’s z-th door changes its state(if it is intact, then it breaks else it joints).
输出解释
For each query, if op equals 0, you should output one line that contains an integer indicates the number of ways from $a_{th}$ floor to the $b_{th}$ floor.
输入样例
3 1
0 1 3
3 2
1 2 1 1
0 1 3
输出样例
8
6
来自杭电HDUOJ的附加信息
Recommend heyang

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #14

源链接: HDU-5068

最后修改于 2020-10-25T23:19:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/3000MS(Java/Others) 32768/32768K(Java/Others)