A Walk Around the Main Campus
Time limit1sMemory limit512 MB
Count closed walks of exactly D minutes from the Information Science Building in a fixed eight-building graph, modulo 1e9+7.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Graph, Matrix
- Solved
- No attempts yet
Problem
The Information Science Building of Soongsil University sits by itself across the road from the rest of the campus. Computer science students therefore call the campus proper the main side and the Information Science Building the CS side. Junyoung is a computer science student, so he is shut up in the Information Science Building and always wants to go over to the main side. One day he decided to take a walk there.
The campus map is below. For this problem, assume the campus has only the eight buildings drawn on it.

Every road between two buildings is two-way, and the adjacency is as follows.
Moving from one building to an adjacent building takes 1 minute. Junyoung never stops on a road or inside a building while walking. He has a lot to do, so he walks for exactly minutes: he starts at the Information Science Building and must be back at the Information Science Building at the moment minutes have passed. He may pass through the same building several times and use the same road several times.
Two routes are different if the sequence of visited buildings differs at any position. Count the possible routes.
Input
The first line contains the integer . ()
Output
Print the number of possible routes modulo .