CF1080F.Katya and Segments Sets

提高+/省选-

通过率:0%

时间限制:3.50s

内存限制:512MB

AC君温馨提醒

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

题目描述

It is a very important day for Katya. She has a test in a programming class. As always, she was given an interesting problem that she solved very fast. Can you solve that problem?

You are given nn ordered segments sets. Each segment can be represented as a pair of two integers [l,r][l, r] where l≤rl\leq r. Each set can contain an arbitrary number of segments (even 00). It is possible that some segments are equal.

You are also given mm queries, each of them can be represented as four numbers: a,b,x,ya, b, x, y. For each segment, find out whether it is true that each set pp (a≤p≤ba\leq p\leq b) contains at least one segment [l,r][l, r] that lies entirely on the segment [x,y][x, y], that is x≤l≤r≤yx\leq l\leq r\leq y.

Find out the answer to each query.

Note that you need to solve this problem online. That is, you will get a new query only after you print the answer for the previous query.

今天对卡佳来说是非常重要的一天。她正在参加一门编程课的测验。和往常一样,她被给出了一道有趣的题目,并且很快就解决了它。你能解决这道题吗?

你将得到 nn 组有序的线段集合。每条线段可表示为一对整数 [l,r][l, r],其中 l≤rl \leq r。每个集合可以包含任意数量的线段(甚至可以为 00)。某些线段可能完全相同。

此外,你还得到 mm 个查询,每个查询由四个整数 a,b,x,ya, b, x, y 表示。对于每个查询,请判断:是否对每个集合 pp(满足 a≤p≤ba \leq p \leq b),该集合中都至少存在一条线段 [l,r][l, r],使得该线段完全落在区间 [x,y][x, y] 内,即满足 x≤l≤r≤yx \leq l \leq r \leq y。

请依次输出每个查询的答案。

注意:你需要在线解决此问题。也就是说,只有在你输出了前一个查询的答案之后,才会收到下一个查询。

输入格式

The first line contains three integers nn, mm, and kk (1≤n,m≤105,1≤k≤3⋅105)(1\leq n,m\leq 10^5, 1\leq k\leq 3\cdot10^5) — the number of sets, queries, and segments respectively.

Each of the next kk lines contains three integers ll, rr, and pp (1≤l≤r≤109,1≤p≤n)(1\leq l\leq r\leq 10^9, 1\leq p\leq n) — the limits of the segment and the index of a set, to which this segment belongs.

Each of the next mm lines contains four integers a,b,x,ya, b, x, y (1≤a≤b≤n,1≤x≤y≤109)(1\leq a\leq b\leq n, 1\leq x\leq y\leq 10^9) — the description of the query.

第一行包含三个整数 nn、mm 和 kk(1≤n,m≤1051\leq n,m\leq 10^5,1≤k≤3⋅1051\leq k\leq 3\cdot10^5)——分别表示集合的数量、查询的数量以及线段的数量。

接下来的 kk 行,每行包含三个整数 ll、rr 和 pp(1≤l≤r≤1091\leq l\leq r\leq 10^9,1≤p≤n1\leq p\leq n)——分别表示该线段的左右端点及其所属集合的编号。

接下来的 mm 行,每行包含四个整数 aa、bb、xx、yy(1≤a≤b≤n1\leq a\leq b\leq n,1≤x≤y≤1091\leq x\leq y\leq 10^9)——表示一次查询的描述。

输出格式

For each query, print "yes" or "no" in a new line.

对于每个查询,在新行中输出 “yes” 或 “no”。

输入输出样例

  • 输入#1

    5 5 9
    3 6 3
    1 3 1
    2 4 2
    1 2 3
    4 6 5
    2 5 3
    7 9 4
    2 3 1
    4 10 4
    1 2 2 3
    1 2 2 4
    1 3 1 5
    2 3 3 6
    2 4 2 9

    输出#1

    no
    yes
    yes
    no
    yes

说明/提示

For the first query, the answer is negative since the second set does not contain a segment that lies on the segment [2,3][2, 3].

In the second query, the first set contains [2,3][2, 3], and the second set contains [2,4][2, 4].

In the third query, the first set contains [2,3][2, 3], the second set contains [2,4][2, 4], and the third set contains [2,5][2, 5].

In the fourth query, the second set does not contain a segment that lies on the segment [3,6][3, 6].

In the fifth query, the second set contains [2,4][2, 4], the third set contains [2,5][2, 5], and the fourth contains [7,9][7, 9].

对于第一个查询,答案是否定的,因为第二个集合不包含位于线段 [2,3][2, 3] 上的任何线段。

在第二个查询中,第一个集合包含 [2,3][2, 3],第二个集合包含 [2,4][2, 4]。

在第三个查询中,第一个集合包含 [2,3][2, 3],第二个集合包含 [2,4][2, 4],第三个集合包含 [2,5][2, 5]。

在第四个查询中,第二个集合不包含位于线段 [3,6][3, 6] 上的任何线段。

在第五个查询中,第二个集合包含 [2,4][2, 4],第三个集合包含 [2,5][2, 5],第四个集合包含 [7,9][7, 9]。

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

首页