ACM: 线段树 poj 2828 认真对待每…
来源:互联网 发布:mac安装jdk 编辑:程序博客网 时间:2024/05/16 06:35
Description
Railway tickets were difficult to buy around the Lunar NewYear in China, so we must get up early and join a longqueue…
The Lunar New Year was approaching, but unluckily the Little Catstill had schedules going here and there. Now, he had to travel bytrain to Mianyang, Sichuan Province for the winter camp selectionof the national team of Olympiad in Informatics.
It was one o’clock a.m. and dark outside. Chill wind from thenorthwest did not scare off the people in the queue. The cold nightgave the Little Cat a shiver. Why not find a problem to thinkabout? That was none the less better than freezing to death!
People kept jumping the queue. Since it was too dark around,such moves would not be discovered even by the people adjacent tothe queue-jumpers. “If every person in the queue is assigned anintegral value and all the information about those who have jumpedthe queue and where they stand after queue-jumping is given, can Ifind out the final order of people in the queue?” Thought theLittle Cat.
Input
There will be several test cases in the input. Each test caseconsists of N + 1 lines where N (1 ≤ N ≤200,000) is given in the first line of the test case. The nextN lines contain the pairs of values Posiand Vali in the increasing order of i (1 ≤i ≤ N). For each i, the ranges and meanings ofPosi and Vali are asfollows:
- Posi ∈ [0, i − 1] — The i-thperson came to the queue and stood right behind thePosi-th person in the queue. The booking officewas considered the 0th person and the person at the front of thequeue was considered the first person in the queue.
- Vali ∈ [0, 32767] — The i-th personwas assigned the value Vali.
There no blank lines between test cases. Proceed to the end ofinput.
Output
For each test cases, output a single line of space-separatedintegers which are the values of people in the order they stand inthe queue.
Sample Input
4
0 77
1 51
1 33
2 69
4
0 20523
1 19243
1 3890
0 31492
Sample Output
77 33 69 51
31492 20523 3890 19243
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 200005
{
}p[MAX];
{
}pt[MAX*4];
int result[MAX];
{
}
{
}
{
//
}
- ACM: 线段树 poj 2828 认真对待每…
- 【线段树】 POJ 2828 Buy Tickets
- ACM: 线段树 poj 1151 足足想了三…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2482 煽情的情书!…
- ACM: 线段树 poj 2352
- ACM: 线段树 poj 1177
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 3264
- ACM: 线段树 poj 3368
- ACM: 线段树 poj 2528 离散化即可
- poj 2828 Buy Tickets(线段树)
- poj 3667 hotel 线段树…
- poj 2892 Tunnel Warfare(线段树…
- poj 1151 Atlantis (线段树+离散+…
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2750 连续最大和
- 运算符与表达式
- ACM: 线段树 poj 1177
- 计算机和资料 转载
- ACM: trie树 poj 2513
- ACM: 线段树 poj 2528 离散化即可
- ACM: 线段树 poj 2828 认真对待每…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2750 连续最大和
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 2482 煽情的情书!…
- C++ 友元类
- ACM: 树状数组 poj 1195