CF1146E.Hot is Cold

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array of nn integers a1,a2,…,ana_1, a_2, \ldots, a_n.

You will perform qq operations. In the ii-th operation, you have a symbol sis_i which is either "<" or ">" and a number xix_i.

You make a new array bb such that bj=−ajb_j = -a_j if ajsixia_j s_i x_i and bj=ajb_j = a_j otherwise (i.e. if sis_i is '>', then all aj>xia_j \gt x_i will be flipped). After doing all these replacements, aa is set to be bb.

You want to know what your final array looks like after all operations.

给你一个包含 nn 个整数的数组 a1,a2,…,ana_1, a_2, \ldots, a_n。

你将执行 qq 次操作。在第 ii 次操作中,你有一个符号 sis_i(其值为 “<” 或 “>”)和一个数字 xix_i。

你构造一个新数组 bb,使得当 ajsixia_j s_i x_i 成立时,bj=−ajb_j = -a_j;否则 bj=ajb_j = a_j(即,若 sis_i 为 “>”,则所有满足 aj>xia_j \gt x_i 的 aja_j 都会被取反)。完成所有这些替换后,令 aa 更新为 bb。

你需要求出经过所有操作后最终的数组。

输入格式

The first line contains two integers n,qn,q (1≤n,q≤1051 \leq n,q \leq 10^5) — the number of integers and the number of queries.

The next line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (−105≤ai≤105-10^5 \leq a_i \leq 10^5) — the numbers.

Each of the next qq lines contains a character and an integer si,xis_i, x_i. (si∈<,>,−105≤xi≤105s_i \in { \lt , \gt }, -10^5 \leq x_i \leq 10^5) – the queries.

第一行包含两个整数 n,qn, q(1≤n,q≤1051 \leq n,q \leq 10^5)—— 分别表示整数的个数和查询的个数。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(−105≤ai≤105-10^5 \leq a_i \leq 10^5)—— 这些数字。

接下来的 qq 行中,每行包含一个字符和一个整数 si,xis_i, x_i(其中 si∈{<,>}, −105≤xi≤105s_i \in \{ \lt , \gt \},\ -10^5 \leq x_i \leq 10^5)—— 表示查询。

输出格式

Print nn integers c1,c2,…,cnc_1, c_2, \ldots, c_n representing the array after all operations.

输出 nn 个整数 c1,c2,…,cnc_1, c_2, \ldots, c_n,表示所有操作后的数组。

输入输出样例

  • 输入#1

    11 3
    -5 -4 -3 -2 -1 0 1 2 3 4 5
    &gt; 2
    &gt; -4
    &lt; 5

    输出#1

    5 4 -3 -2 -1 0 1 2 -3 4 5
  • 输入#2

    5 5
    0 1 -2 -1 2
    &lt; -2
    &lt; -1
    &lt; 0
    &lt; 1
    &lt; 2

    输出#2

    0 -1 2 -1 2

说明/提示

In the first example, the array goes through the following changes:

  • Initial: [−5,−4,−3,−2,−1,0,1,2,3,4,5][-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]
  • $ \gt 2$: [−5,−4,−3,−2,−1,0,1,2,−3,−4,−5][-5, -4, -3, -2, -1, 0, 1, 2, -3, -4, -5]
  • $ \gt -4$: [−5,−4,3,2,1,0,−1,−2,3,−4,−5][-5, -4, 3, 2, 1, 0, -1, -2, 3, -4, -5]
  • $ \lt 5$: [5,4,−3,−2,−1,0,1,2,−3,4,5][5, 4, -3, -2, -1, 0, 1, 2, -3, 4, 5]

在第一个例子中,数组经历了以下变化:

  • 初始:[−5,−4,−3,−2,−1,0,1,2,3,4,5][-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]
  • $ \gt 2$: [−5,−4,−3,−2,−1,0,1,2,−3,−4,−5][-5, -4, -3, -2, -1, 0, 1, 2, -3, -4, -5]
  • $ \gt -4$: [−5,−4,3,2,1,0,−1,−2,3,−4,−5][-5, -4, 3, 2, 1, 0, -1, -2, 3, -4, -5]
  • $ \lt 5$: [5,4,−3,−2,−1,0,1,2,−3,4,5][5, 4, -3, -2, -1, 0, 1, 2, -3, 4, 5]

输入解题思路,AI测评打分。不知道怎么写?

首页