Problem D
Veður - Vegakerfi
Languages
en
is
Vegagerðin has contacted you again regarding another assignment. A lot of Icelanders are travelling across the country despite the bad weather. As a result Vegagerðin gets a lot of inquiries, for example, whether it’s possible to travel from Kópavogur to Egilsstaðir given the current conditions.
Vegagerðin gives you a description of Iceland’s road system where every road in the country is described. Each road is described by its two endpoints and a wind speed threshold. If the wind speed is less than or equal to the threshold the road is open, but otherwise it is closed.
Now you need to write a program that can answer these queries. Queries consist of a starting point, an endpoint and the current wind speed over the country. The reply should be Jebb if there is a route from the starting point to the end point using only open roads. Otherwise the reply should be Neibb.
Input
The first line of the input contains three integers $n$ ($1 \leq n \leq 10^5$), the number of intersections, $m$ ($0 \leq m \leq 10^5)$, the number of roads, and $q$ ($1 \leq q \leq 10^5)$, the number of queries.
Next there are $m$ lines, where the $i$-th line describes road number $i$. Each line consists of three integers $u_ i$ ($1 \leq u_ i \leq n$) and $v_ i$ ($1 \leq v_ i \leq n$), the end points of the road, and $t_ i$ ($0 \leq t_ i \leq 10^9$), its wind speed threshold.
Finally there are $q$ lines, where the $j$-th line describes query number $j$. To ensure that the queries are answered one at a time, they are encrypted. Each line thus contains three encrypted integers $a’_ j$, $b’_ j$ and $h’_ j$. Let us denote the number of queries that have been answered with Jebb up to this point by $x$. To get the correct values of $a_ j, b_ j$ and $h_ j$ the XOR operation should be used, denoted by ${}^\wedge {}$ in most programming languages, so
-
$a_ j = a’_ j {}^\wedge {} x$,
-
$b_ j = b’_ j {}^\wedge {} x$,
-
$h_ j = h’_ j {}^\wedge {} x$.
Each query thus contains three integers $a_ j$ ($1 \leq a_ j \leq n$), the starting point, $b_ j$ ($1 \leq b_ j \leq n)$, endpoint and $h_ j$ ($0 \leq h_ j \leq 10^9$), the wind speed.
Output
For each query either Jebb should be printed, if there is a route from the starting point to the end point using no closed roads, or Neibb otherwise.
Scoring
Group |
Points |
Constraints |
||
1 |
10 |
|
||
2 |
30 |
$1 \leq n, q \leq 100$, queries are in descending order by wind speed. |
||
3 |
20 |
$1 \leq n \leq 250$, queries are in descending order by wind speed. |
||
4 |
30 |
Queries are in descending order by wind speed. |
||
5 |
10 |
No further constraints. |
Sample Input 1 | Sample Output 1 |
---|---|
4 4 2 1 2 7 2 3 5 3 4 4 4 1 3 2 4 6 1 4 4 |
Neibb Jebb |