時間限制 2000 ms ・ 記憶體限制 256 MB
題目描述
小紅帽從網格左下角 (0,0) 前往奶奶家 (w,h),每步只能向右或向上。狼可能出現在若干交叉點,路徑不得經過這些點。請計算安全路徑總數。
輸入格式
每筆第一行為 w h(1 ≤ w,h ≤ 100),下一行為狼的位置數 n(0 ≤ n ≤ 100),再接 n 行座標 x y。狼不會位於起點或終點。以 w = h = 0 結束。答案保證不超過 2³²−1。
輸出格式
無路徑時輸出 There is no path.。恰一條時輸出 There is one path from Little Red Riding Hood's house to her grandmother's house.。超過一條時輸出 There are X paths from Little Red Riding Hood's house to her grandmother's house.,X 為路徑數。每筆占一行。
範例測資
範例輸入 1
1 1 0 1 1 2 0 1 1 0 4 4 3 0 1 1 1 3 1 10 10 0 10 10 3 0 1 1 1 1 0 3 3 5 1 0 1 1 1 2 2 2 3 2 0 0
範例輸出 1
There are 2 paths from Little Red Riding Hood's house to her grandmother's house. There is no path. There are 7 paths from Little Red Riding Hood's house to her grandmother's house. There are 184756 paths from Little Red Riding Hood's house to her grandmother's house. There is no path. There is one path from Little Red Riding Hood's house to her grandmother's house.
請先登入後再提交程式碼
討論與題解
載入討論區…