SUNC Algorithms 2019-2020. Bitwise Optimization SUNC MSU, October 17, 2019 Task A. Path…
- User
SUNC Algorithms 2019-2020. Bitwise Optimization
SUNC MSU, October 17, 2019Task A. Path Strings
Input File Name: "standard input"
Output File Name: "standard output"
Time Limit: 1 second
Memory Limit: 256 megabytesConsider a directed graph (G) with (n) vertices, numbered from 1 to (n). The graph (G) may have multiple edges between the same pair of vertices, as well as loops (edges leading from a vertex to itself). Each edge in the graph is labeled with a letter from the Latin alphabet. Every path in the graph (G) can be associated with a string made up of the letters written on the edges traversed in that path. This string is called the path label of the path. We will call a string (S) a path string of the graph (G) if there exists a path in the graph whose path label matches (S).
Your task is to find the remainder of the number of path strings of length (L) in the graph (G) when divided by 1,000,000.
Input Format
The first line of the input contains three integers (n, m, L) ((1 \leq n \leq 10), (1 \leq m \leq 10,000), (1 \leq L \leq 100)), representing the number of vertices, the number of edges in the graph (G), and the length of the path strings to be found, respectively.
The next (m) lines describe the edges of the graph (G). Each of these lines contains two natural numbers (a, b) ((1 \leq a, b \leq n)) and a lowercase Latin letter (c), indicating an edge from vertex (a) to vertex (b) labeled with the symbol (c). The elements in each line are separated by spaces.
Output Format
The output should contain a single number: the remainder of the number of path strings of length (L) in the graph (G) when divided by 1,000,000.
Example
Input:
code4 4 100 1 2 a 1 3 a 3 4 a 4 1 bOutput:
code2 ``` solve in c++ - Assistant