| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 2 | 1 | 1 | 100.000% |
Gigel has an undirected graph $G$ with $N$ nodes and $M$ edges with positive costs. After the mess Gigel got into at the Romanian National Olympiad in Informatics, Ninel, Gigel's little brother, stole all his edges. Gigel wants to get the edges back, but Ninel is going to make him go through some challenges.
You are given an array of undirected edges $S$ of length $L$. Every edge has a regular cost, but it also has a rejection cost $r$. Gigel has to accomplish the following mission he got from Ninel: find the minimum cost of going from node $u$ to node $v$ using a subarray of edges of $S$. Gigel is given an interval $[a,b](a≤b)$ which determines the indices of the edges in $S$ he is allowed to use.
Gigel is initially in node $x$ and he iterates over the edges $S_a,S_{a+1},\dots ,S_b$. At each step:
You know the number of nodes $N,ドル the array of edges $S$ and $Q$ missions Gigel needs to accomplish.
The array $S$ consists of tuples of the form:
The $Q$ missions are tuples of the form:
Find the minimum cost for each mission. If Gigel cannot reach node $v$ output $-1$.
The first line contains three integers $N,ドル $L$ and $Q$.
The next $L$ lines contain four integers $x,y,c,r$ corresponding to the edges in $S$.
The next $Q$ lines contain four integers $u,v,a,b$ corresponding to Gigel's missions.
Print $Q$ lines, each containing the answer for one of Gigel's missions, in the given order.
5 5 3 1 4 4 5 4 1 6 1 2 1 2 9 2 5 1 0 1 5 2 5 2 2 2 4 5 4 5 5 1 5 2 5
10 -1 9
4 8 6 2 4 5 8 2 4 4 8 2 3 6 4 1 4 5 0 2 4 10 10 1 3 5 2 3 2 2 9 3 4 1 1 3 2 1 5 3 1 2 2 1 1 1 7 2 3 2 4 3 3 1 7 1 2 2 5
32 -1 41 14 36 27