Multi-stage Marathon
Time limit3sMemory limit512 MB
Given a directed graph of up to 70 checkpoints and players entering at set times, compute the XOR over all moments 1 to T of the expected number of players at checkpoint n, modulo 1e9+7.
- Level
Hard9 of 10
- Topics
- Matrix, Dynamic programming, Math
- Solved
- No attempts yet
Problem
Bobo is organizing a marathon contest. The contest has checkpoints, labeled . You are given a binary matrix . means there is a directed road from checkpoint to checkpoint , and means there is no such road.
There are players. The -th player starts at checkpoint at moment . The road system is complicated, so players move randomly. If a player is at checkpoint at moment , then at moment the player appears at each checkpoint with with equal probability.
Let , where is the expected number of players at checkpoint at moment , and . Bobo wants to know , where is bitwise exclusive or.
Input
The first line contains three integers , , and (, , ). Each of the next lines contains a binary string of length . It is guaranteed that . Each of the last lines contains two integers and (, ).
Output
Print one integer, the result.