CF631C.Report
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes corresponding revenue. Before the report gets to Blake, it passes through the hands of m managers. Each of them may reorder the elements in some order. Namely, the i-th manager either sorts first r__i numbers in non-descending or non-ascending order and then passes the report to the manager i + 1, or directly to Blake (if this manager has number i = m).
Employees of the "Blake Technologies" are preparing the report right now. You know the initial sequence a__i of length n and the description of each manager, that is value r__i and his favourite order. You are asked to speed up the process and determine how the final report will look like.
每个月,布莱克都会收到一份包含“布莱克科技”公司主要经济指标的报告。该公司生产 n 种商品,报告中对每种商品恰好有一个整数,表示其对应的收入。在报告送达布莱克之前,需依次经过 m 位经理之手。每位经理都可能对报告中的某些元素重新排序。具体而言,第 i 位经理要么将前 ri 个数按非降序(升序)排列,要么按非升序(降序)排列,然后将报告传递给第 i+1 位经理(若 i=m,则直接交给布莱克)。
目前,“布莱克科技”的员工正在准备这份报告。你已知初始序列 ai(长度为 n)以及每位经理的操作描述,即参数 ri 及其偏好的排序方式(升序或降序)。你的任务是加速该过程,确定最终报告的序列形态。
输入格式
The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the number of commodities in the report and the number of managers, respectively.
The second line contains n integers a__i (|a__i| ≤ 109) — the initial report before it gets to the first manager.
Then follow m lines with the descriptions of the operations managers are going to perform. The i-th of these lines contains two integers t__i and r__i (
, 1 ≤ r__i ≤ n), meaning that the i-th manager sorts the first r__i numbers either in the non-descending (if t__i = 1) or non-ascending (if t__i = 2) order.
输入的第一行包含两个整数 n 和 m(1 ≤ n, m ≤ 200000),分别表示报告中商品的数量和经理的数量。
第二行包含 n 个整数 ai(∣ai∣ ≤ 109),表示传给第一位经理前的初始报告。
接下来是 m 行,描述各位经理将执行的操作。第 i 行包含两个整数 ti 和 ri(
,1 ≤ ri ≤ n),表示第 i 位经理将对前 ri 个数进行排序:若 ti=1,则按非降序排列;若 ti=2,则按非升序排列。
输出格式
Print n integers — the final report, which will be passed to Blake by manager number m.
输出 n 个整数——即最终报告,该报告将由编号为 m 的经理提交给 Blake。
输入输出样例
输入#1
3 1 1 2 3 2 2
输出#1
2 1 3
输入#2
4 2 1 2 4 3 2 3 1 2
输出#2
2 4 1 3
说明/提示
In the first sample, the initial report looked like: 1 2 3. After the first manager the first two numbers were transposed: 2 1 3. The report got to Blake in this form.
In the second sample the original report was like this: 1 2 4 3. After the first manager the report changed to: 4 2 1 3. After the second manager the report changed to: 2 4 1 3. This report was handed over to Blake.
在第一个样例中,初始报告如下:1 2 3。经过第一位经理后,前两个数字被交换:2 1 3。该报告以此形式交至 Blake 手中。
在第二个样例中,原始报告如下:1 2 4 3。经过第一位经理后,报告变为:4 2 1 3。经过第二位经理后,报告变为:2 4 1 3。该报告被交至 Blake 手中。
输入解题思路,AI测评打分。不知道怎么写?