#P8856. [POI 2002 R1] 火车线路

[POI 2002 R1] 火车线路

Problem Description

A train departs from city 11 and travels to city CC. The train has SS seats, and there are RR ticket booking requests.

Each booking request consists of three integers O,D,NO, D, N, meaning that NN seats are requested for the trip from station OO to station DD.

If there are enough available seats throughout the requested segment, then the request can be satisfied; otherwise, it cannot.

Process the requests in the given order, and determine whether each request can be satisfied.

Input Format

The first line contains three integers C,S,RC, S, R.

The next RR lines each contain three integers O,D,NO, D, N, describing one booking.

Output Format

For the ii-th booking, if it can be satisfied, output T, otherwise output N.

4 6 4
1 4 2
1 3 2
2 4 3
1 2 3
T
T
N
N

Hint

Constraints: 1C,S,R600001 \le C, S, R \le 60000.

Translated by ChatGPT 5