CF1599F.Mars

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

In the year 2420 humans have finally built a colony on Mars thanks to the work of Elon Tusk. There are 109+710^9+7 cities arranged in a circle in this colony and none of them are connected yet. Elon Tusk wants to connect some of those cities using only roads of the same size in order to lower the production cost of those roads. Because of that he gave a list on N cites where some cites can appear more than once and Q queries that you need to answer. For the query you need to determine if it is possible to connect all the cities from LiL_{i} to RiR_{i} on that list using only roads of length DiD_{i}.

在2420年,人类终于在火星上建立了殖民地,这得益于埃隆·塔斯克(Elon Tusk)的工作。该殖民地共有 109+710^9+7 座城市,呈环形排列,且目前任意两座城市之间均未连通。埃隆·塔斯克希望仅使用长度完全相同的道路来连接其中一部分城市,以降低这些道路的生产成本。为此,他提供了一个包含 NN 座城市的列表(某些城市可能在列表中重复出现)以及 QQ 个查询,你需要回答所有这些查询。对于每个查询,你需要判断:是否能仅使用长度为 DiD_i 的道路,将该列表中从第 LiL_i 个位置到第 RiR_i 个位置的所有城市全部连通。

输入格式

The first line contains two integers NN and QQ (1≤N,Q≤2⋅1051 \leq N, Q \leq 2\cdot10^5 ) — the length of the array of cities and the number of queries you need to answer.

The second lines contains NN integers representing the array of cites. Next Q lines contain three integers L,RL, R and DD (1≤Li,Ri≤N1 \leq L_{i}, R_{i} \leq N, 0≤Di≤109+60 \leq D_{i} \leq 10^9+6) — the range of cities that needs to be connected and the length of the road that you can use.

第一行包含两个整数 NN 和 QQ(1≤N,Q≤2⋅1051 \leq N, Q \leq 2\cdot10^5),分别表示城市数组的长度以及需要回答的查询数量。

第二行包含 NN 个整数,表示城市数组。接下来的 QQ 行每行包含三个整数 LL、RR 和 DD(1≤Li,Ri≤N1 \leq L_{i}, R_{i} \leq N,0≤Di≤109+60 \leq D_{i} \leq 10^9+6),表示需要连通的城市区间以及可使用的道路长度。

输出格式

The output contains Q lines. If it is possible to connect all the cities from the i-th query can be connected with roads of length DiD_{i} the i-th line should contain the word "Yes", otherwise it should contain the word "No".

输出包含 QQ 行。对于第 ii 个查询,如果能够使用长度为 DiD_{i} 的道路将所有城市连通,则第 ii 行应输出单词 “Yes”,否则应输出单词 “No”。

输入输出样例

  • 输入#1

    9 8
    17 0 12 6 10 8 2 4 5
    2 3 12
    2 3 6
    2 4 6
    4 6 2
    2 8 2
    1 2 17
    1 8 2
    9 9 14

    输出#1

    Yes
    No
    Yes
    Yes
    Yes
    Yes
    No
    Yes
  • 输入#2

    4 1
    7 21 14 0
    1 4 1000000000

    输出#2

    Yes

说明/提示

In the 5th5^{th} query of the first test case we can connect cities in this order 0-2-4-6-8-10-12 this way distance between any two connected cities is 2. In the second test case we can connect cities in this order 21-14-7-0 this way distance between any two connected cities is 10910^9 module 109+710^9+7.

在第一个测试用例的第 5 次查询中,我们可以按如下顺序连接城市:0-2-4-6-8-10-12,这样任意两个相连城市之间的距离均为 2。在第二个测试用例中,我们可以按如下顺序连接城市:21-14-7-0,这样任意两个相连城市之间的距离为 10910^9 对 109+710^9+7 取模。

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

首页