Codeforces Round 359 (Div. 1)
E
Travelling Through the Snow Queen's Kingdom
Codeforces
2800
原题
← D→
翻译中…

Gerda is travelling to the palace of the Snow Queen.

翻译中…

The road network consists of $*n*$ intersections and $*m*$ bidirectional roads. Roads are numbered from $1$ to $*m*$. Snow Queen put a powerful spell on the roads to change the weather conditions there. Now, if Gerda steps on the road $*i*$ at the moment of time less or equal to $*i*$, she will leave the road exactly at the moment $*i*$. In case she steps on the road $*i*$ at the moment of time greater than $*i*$, she stays there forever.

翻译中…

Gerda starts at the moment of time $*l*$ at the intersection number $*s*$ and goes to the palace of the Snow Queen, located at the intersection number $*t*$. Moreover, she has to be there at the moment $*r*$ (or earlier), before the arrival of the Queen.

翻译中…

Given the description of the road network, determine for $*q*$ queries $*l*_{*i*}$, $*r*_{*i*}$, $*s*_{*i*}$ and $*t*_{*i*}$ if it's possible for Gerda to get to the palace on time.

翻译中…

Input

翻译中…

The first line of the input contains integers $*n*$, $*m*$ and $*q*$ ($2 ≤ *n* ≤ 1000$, $1 ≤ *m*, *q* ≤ 200 000$) — the number of intersections in the road network of Snow Queen's Kingdom, the number of roads and the number of queries you have to answer.

翻译中…

The $*i*$-th of the following $*m*$ lines contains the description of the road number $*i*$. The description consists of two integers $*v*_{*i*}$ and $*u*_{*i*}$ ($1 ≤ *v*_{*i*}, *u*_{*i*} ≤ *n*$, $*v*_{*i*} ≠ *u*_{*i*}$) — the indices of the intersections connected by the $*i*$-th road. It's possible to get both from $*v*_{*i*}$ to $*u*_{*i*}$ and from $*u*_{*i*}$ to $*v*_{*i*}$ using only this road. Each pair of intersection may appear several times, meaning there are several roads connecting this pair.

翻译中…

Last $*q*$ lines contain the queries descriptions. Each of them consists of four integers $*l*_{*i*}$, $*r*_{*i*}$, $*s*_{*i*}$ and $*t*_{*i*}$ ($1 ≤ *l*_{*i*} ≤ *r*_{*i*} ≤ *m*$, $1 ≤ *s*_{*i*}, *t*_{*i*} ≤ *n*$, $*s*_{*i*} ≠ *t*_{*i*}$) — the moment of time Gerda starts her journey, the last moment of time she is allowed to arrive to the palace, the index of the starting intersection and the index of the intersection where palace is located.

翻译中…

Output

翻译中…

For each query print "Yes" (without quotes) if Gerda can be at the Snow Queen palace on time (not later than $*r*_{*i*}$) or "No" (without quotes) otherwise.

翻译中…

样例

Input #1
5 4 6
1 2
2 3
3 4
3 5
1 3 1 4
1 3 2 4
1 4 4 5
1 4 4 1
2 3 1 4
2 2 2 3
Output #1
Yes
Yes
Yes
No
No
Yes
InputCopy OutputCopy
题目信息
题号
685E
时间限制
1.5 s
内存限制
256 MB
标签
位运算
暴力
分治
图论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。