Logo
(追記) (追記ここまで)

33726번 - Mi Teleférico 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB80262533.333%

문제

La Paz, the capital city of Bolivia, is famous as a tourist spot and for an aerial cable car called Mi Teleférico. You are now visiting La Paz for sightseeing, and you want to visit as many sightseeing places as possible. In this task, we consider the following simplified situation.

There are $N$ aerial cable car stations in La Paz, numbered from 1ドル$ to $N$ in ascending order of altitude. There are $M$ one-way lines, numbered from 1ドル$ to $M$. There are $P$ aerial cable car companies, numbered from 1ドル$ to $P$. Each line is managed by a single company. Line $i$ (1ドル ≤ i ≤ M$) is operated from station $A_i$ to station $B_i,ドル and is managed by the company $C_i$. Here, the line always runs from the lower altitude station to the higher altitude station. In other words, $A_i < B_i$ holds.

The Bureau of transportation of La Paz issued unlimited ride passes for convenience. Each ride pass contains 2ドル$ integers $l,ドル $r,ドル which satisfy 1ドル ≤ l ≤ r ≤ P$. The pass enables the possessor to ride lines, which are managed by any one of company $l, l + 1, \dots ,r$. In other words, for an integer $i$ which satisfies 1ドル ≤ i ≤ M,ドル the pass enables the possessor to ride line $i$ when $l ≤ C_i ≤ r$ holds. It is possible to use a single pass for several lines. Let a ride pass $(l,r)$ denote this ride pass.

Now, $Q$ tourists, numbered from 1ドル$ to $Q,ドル visit La Paz. Tourist $j$ (1ドル ≤ j ≤ Q$) has a ride pass $(L_j, R_j)$ and $X_j$ boliviano cash.

Each tourist’s goal is to ensure that no station cannot be travelled from station 1ドル,ドル using only lines that can be ridden with the ride pass he or she has. Tourist $j$ (1ドル ≤ j ≤ Q$) can exchange his or her ride pass described in the following process to achieve their goal. Here, each tourist can exchange at most once.

  1. He or she chooses 2ドル$ integers $l',ドル $r',ドル which satisfy 1ドル ≤ l' ≤ r' ≤ P$.
  2. He or she exchanges a ride pass $(L_j, R_j)$ for a ride pass $(l', r')$. It costs $|L_j − l'| + |R_j − r'|$ boliviano as a fee.

Your purpose is to determine, for each tourist, whether or not he or she can achieve his or her goal within the cash he or she has.

Write a program which, given information about stations, lines, and tourists, determines whether or not he or she can achieve his or her goal within the cash he or she has for each tourist.

입력

Read the following data from the standard input.

$N$ $M$ $P$

$A_1$ $B_1$ $C_1$

$A_2$ $B_2$ $C_2$

$\vdots$

$A_M$ $B_M$ $C_M$

$Q$

$L_1$ $R_1$ $X_1$

$L_2$ $R_2$ $X_2$

$\vdots$

$L_Q$ $R_Q$ $X_Q$

출력

Write $Q$ lines to the standard output. On the $j$-th line (1ドル ≤ j ≤ Q$), output Yes if tourist $j$ can achieve his or her goal, and No otherwise.

제한

  • 2ドル ≤ N ≤ 300,円 000$.
  • 1ドル ≤ M ≤ 300,円 000$.
  • 1ドル ≤ P ≤ 10^9$.
  • 1ドル ≤ A_i < B_i ≤ N$ (1ドル ≤ i ≤ M$).
  • 1ドル ≤ C_i ≤ P$ (1ドル ≤ i ≤ M$).
  • 1ドル ≤ Q ≤ 400,円 000$.
  • 1ドル ≤ L_j ≤ R_j ≤ P$ (1ドル ≤ j ≤ Q$).
  • 0ドル ≤ X_j ≤ 10^9$ (1ドル ≤ j ≤ Q$).
  • Given values are all integers.

서브태스크

번호배점제한
17

$N ≤ 50,ドル $M ≤ 50,ドル $Q ≤ 50,ドル $X_j = 0$ (1ドル ≤ j ≤ Q$).

28

$P ≤ 10$.

311

$P ≤ 100$.

423

$P ≤ 300,円 000,ドル $X_j = 0$ (1ドル ≤ j ≤ Q$).

59

$P ≤ 300,円 000$.

622

$N ≤ 8,円 000,ドル $M ≤ 8,円 000$.

720

No additional constraints.

예제 입력 1

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

예제 출력 1

Yes
No
No
Yes

First, tourist 1ドル$ has a ride pass $(3, 7)$ and 0ドル$ boliviano cash initially. He or she can achieve his or her goal without exchange. Because, this pass enables tourist 1ドル$ to ride 4ドル$ lines, lines 1ドル,ドル 2ドル,ドル 3ドル,ドル 4ドル,ドル and he or she can move to each stations from station 1ドル$ by using these 4ドル$ lines as follows.

  • It is possible to move as station 1ドル → 2$ by using line 3ドル$.
  • It is possible to move as station 1ドル → 2 → 3$ by using lines 1ドル,ドル 4ドル$ in this order.
  • It is possible to move as station 1ドル → 2 → 4$ by using lines 3ドル,ドル 2ドル$ in this order.

Therefore, output Yes on the 1ドル$-st line.

Next, tourist 2ドル$ has a ride pass $(5, 6)$ and 0ドル$ boliviano cash initially. However, He or she can’t achieve his or her goal. Because, this pass enables tourist 2ドル$ to ride 2ドル$ lines, lines 3ドル,ドル 4ドル,ドル and he or she can’t move station 4ドル$ from station 1ドル$ by using these 2ドル$ lines. Moreover, since tourist 2ドル$ has only 0ドル$ boliviano as cash, he or she can’t exchange the pass with another pass.

Hence, output No on the 2ドル$-nd line.

Also, tourist 3ドル$ can’t achieve his or her goal, and tourist 4ドル$ can achieve his or her goal. Thus, output No on the 3ドル$-rd line, and output Yes on the 4ドル$-th line.

This sample input satisfies the constraints of all the Subtasks.

예제 입력 2

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

예제 출력 2

Yes
No
Yes

The information of stations and lines is the same as in the sample Input 1.

First, tourist 1ドル$ has a ride pass $(5, 6)$ and 10ドル$ boliviano cash initially. He or she can achieve his or her goal with exchange as below.

  1. He or she chooses 2ドル$ integers $l' = 1,ドル $r' = 5,ドル which satisfy 1ドル ≤ l' ≤ r' ≤ P$.
  2. He or she exchange a ride pass $(5, 6)$ for a ride pass $(1, 5)$. It costs $|5 − 1| + |6 − 5| = 5$ boliviano as a fee.

Therefore, output Yes on the 1ドル$-st line.

Next, tourist 2ドル$ has a ride pass $(3, 4)$ and 1ドル$ boliviano cash initially. He or she can’t achieve his or her goal with any exchange.

Consequently, output No on the 2ドル$-nd line.

Since Tourist 3ドル$ can achieve his or her goal, output Yes on the 3ドル$-rd line.

This sample input satisfies the constraints of Subtasks 2, 3, 5, 6, 7.

예제 입력 3

3 1 1000000000
1 2 6
1
1 1000000000 1000000000

예제 출력 3

No

It is not possible to move from station 1ドル$ to station 3ドル$ with these lines, so tourists can’t achieve their goal regardless of their ride passes.

This sample input satisfies the constraints of Subtasks 6, 7.

예제 입력 4

5 9 2000
2 3 1814
2 3 457
1 2 1226
3 4 1354
1 5 1050
1 2 1725
2 3 1383
1 5 1626
1 4 1795
5
850 1872 128
82 428 1217
487 924 573
1639 1926 202
202 420 25

예제 출력 4

Yes
Yes
Yes
Yes
No

This sample input satisfies the constraints of Subtasks 5, 6, 7.

힌트

출처

Olympiad > Japanese Olympiad in Informatics > JOI 2024/2025 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /