CF685E.Travelling Through the Snow Queen's Kingdom

省选/NOI-

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

格达正在前往冰雪女王的宫殿。

道路网络由 nn 个交叉路口和 mm 条双向道路组成。道路编号为 11 到 mm。冰雪女王在道路上施加了强大的魔法,以改变其天气状况。现在,若格达在时刻 ≤i\le i 踏上第 ii 条道路,则她将恰好在时刻 ii 离开该道路;若她在时刻 >i> i 踏上第 ii 条道路,则她将永远滞留在该道路上。

格达于时刻 ll 从编号为 ss 的交叉路口出发,前往位于编号为 tt 的交叉路口的冰雪女王宫殿。此外,她必须在时刻 rr(或更早)抵达宫殿,即在女王到达之前抵达。

给定道路网络的描述,请对 qq 组查询 (li,ri,si,ti)(l_i, r_i, s_i, t_i),判断格达能否及时抵达宫殿。

输入格式

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.

输入的第一行包含三个整数 nn、mm 和 qq(2 ≤ n ≤ 10002 ≤ n ≤ 1000,1 ≤ m, q ≤ 200 0001 ≤ m, q ≤ 200\,000)——分别表示雪女王王国道路网络中的交叉路口数量、道路数量以及你需要回答的查询数量。

接下来的 mm 行中,第 ii 行描述第 ii 条道路:包含两个整数 viv_i 和 uiu_i(1 ≤ vi, ui ≤ n1 ≤ v_i, u_i ≤ n,vi ≠ uiv_i ≠ u_i),表示该道路所连接的两个交叉路口的编号。仅通过这条道路即可在 viv_i 与 uiu_i 之间双向通行。同一对交叉路口可能出现多次,意味着它们之间可能存在多条道路。

最后 qq 行为查询描述。每行包含四个整数 lil_i、rir_i、sis_i 和 tit_i(1 ≤ li ≤ ri ≤ m1 ≤ l_i ≤ r_i ≤ m,1 ≤ si, ti ≤ n1 ≤ s_i, t_i ≤ n,si ≠ tis_i ≠ t_i)——分别表示格尔达出发的时刻、她被允许抵达宫殿的最晚时刻、起点交叉路口的编号以及宫殿所在交叉路口的编号。

输出格式

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.

对于每个查询,如果格达能准时(不晚于 rir_i)到达雪女王宫殿,则输出“Yes”(不带引号),否则输出“No”(不带引号)。

输入输出样例

  • 输入#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

    输出#1

    Yes
    Yes
    Yes
    No
    No
    Yes

输入解题思路,AI测评打分。不知道怎么写?

首页