#P1535. [USACO08MAR] Cow Travelling S
[USACO08MAR] Cow Travelling S
Description
Cows wander on a pasture divided into rows and columns (), trying to find the tastiest grass.
At some moment, Farmer John sees Bessie at position . Exactly () seconds later, FJ runs into Bessie at position . FJ does not know whether Bessie visited at any time during those seconds; he only knows that she is there now.
Let be the number of paths the cow can take to go from to in seconds. FJ wants a program to compute this value. Each second, the cow moves horizontally or vertically by a distance of (the cow is always moving and will not stay at the same point in any second). Some places on the pasture have trees. Of course, the cow cannot step on a tree, and she will not leave the pasture.
You are given a map of the whole pasture, where . means open grass and * means a blocking tree. Your task is to compute how many different paths a cow can take to move from to in seconds.
Input Format
The first line contains space-separated integers: .
Then lines follow: the -th line has consecutive characters describing row of the pasture. Each character is guaranteed to be either . or *.
The last line contains integers .
Output Format
Output the number of ways to move from to .
4 5 6
...*.
...*.
.....
.....
1 3 1 5
1
Hint
There is only one way for the cow to go from to in seconds, by going around the tree in front of her.
Translated by ChatGPT 5
京公网安备 11011102002149号