410803: GYM104118 E Escape from Markov

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Escape from Markovtime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputExamplesInput
4 4 1 4
1 2
2 3
3 4
4 1
2 1 4 3
1 3
Output
2
Input
4 4 1 4
1 2
2 3
3 4
4 1
2 1 4 3
1 2
Output
2
Input
6 5 1 4
1 2
2 3
3 4
4 5
5 6
5 6 5 4
1 6
Output
7
Input
2 1 1 2
1 2
2 1
1 2
Output
IMPOSSIBLE

加入题单

算法标签: