report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Escape from... dolls - FlandreOJ: Flandre Online Judge

Escape from... dolls

Time limit: 1000 ms
Memory limit: 256 MB
Marisa is being chased by $k$ Alice's dolls. What Marisa has done to Alice, I will leave that to your imagination... Marisa is now at vertex $1$ of an connected, undirected graph of $n$ vertices and $m$ edges. The $i^{th}$ doll is at vertex $A_i$. Marisa and dolls can move to any adjacent vertex in $1$ unit of time. The dolls always move optimally to chase Marisa. Marisa can escape these dolls after reaching vertex $n$. If she encounters $x$ dolls at a vertex (even at vertex $n$), she must fight them and they will stop chasing her. This action costs her $x$ energy, but does not take time. What is the minimum amount of energy she must spend to escape? ### Input - The first line contains 3 integers $n, m, k$. - The second line contains $k$ integers $A_i$. - The next $m$ lines, each line contains 2 integers $u, v$, there is an edge between $u$ and $v$. ### Output - Print the minimum amount of energy Marisa must use to escape. ### Constraints - $1 \le n, m, k \le 10^5$. - $1 \le u, v, A_i \le n$. ### Example Input: ``` 6 6 2 2 4 1 2 1 3 3 4 2 4 4 5 3 6 ``` Output: ``` 1 ``` #### Note: She has to fight the second doll.
BFS / DFS
Connected component
Shortest path
Finding the path
Path on binary matrix
Garden
Operations on number
Bipartite graph
Tom and Jerry
Festival 1
Bamboo Forest of the Lost
Radar
Festival 2
Go
Escape from... dolls
Long leg
Lexicographically smallest path
Graph coloring
Topic
Graph
Shortest path
Rating 1500
Solution (1) Solution