Nội dung Bài tập
Mã:
ACM2016_North_I
Tên:
Festivals (ACM 2016 Miền Bắc)
Dạng thi:
acm
Thang điểm:
1 điểm
Giới hạn thời gian:
5 giây
Giới hạn bộ nhớ:
64 MB
Được tạo bởi:
admin

Jack is such a naughty boy that he can't stop himself from hanging out with friends in his leisure time. Recently, he has been informed that his city will organize a lot of festivals to celebrate New Year. Wonderful!

There are N festivals which will be held at N places on the main street of Jack's city. It is possible to have more than one event at each place. Festival i will take place at position Xi from day Si to day Ei. Besides, Jack also evaluates festival i by the attractive value Vi. Jack and his friends have listed out M possible plans. For plan j, they will travel from position Lj to position Rj on day Dj. However, they don't have much time thus they will only join the festival which is the most attractive on their way (highest value V).

Your task is to help them know what is maximum attractive value of a festival they can join for each plan. If there is no such festival, output -1.


Input
The input starts with the number of test - T (T  5). Then T tests follow:
•    The first line contains the number of festivals N (1  N  100.000).
•    The i-th line of N following lines contains 4 integers Xi, Si, Eand Vi (Xi, Si, Ei, Vi  109; Si ≤ Ei)
•    Next line contains the number of plans M (1  M  100.000).
•    The j-th line of M following lines contains 3 integer Dj, Lj and  Rj. (1  Lj, Rj, Dj   109; Lj  Rj)

Output
For each test, print M lines containing the results for M plans.

 

Ví dụ

  • input
    1 4
    2 4 8 11
    3 10 14 27
    4 6 12 19
    6 1 16 8
    4
    6 1 4
    7 2 3
    15 3 9
    16 3 4
    output
    19
    11
    8
    -1

    Quảng cáo
       Ngôn ngữ : 

       Theme : 
Mời bạn soạn code



		



      Ai có thể xem bài này : 

Thông tin



Phần thảo luận