CF1146E.Hot is Cold
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array of n integers a1,a2,…,an .
You will perform q operations. In the i -th operation, you have a symbol si which is either "<" or ">" and a number xi .
You make a new array b such that bj=−aj if ajsixi and bj=aj otherwise (i.e. if si is '>', then all aj>xi will be flipped). After doing all these replacements, a is set to be b .
You want to know what your final array looks like after all operations.
输入格式
The first line contains two integers n,q ( 1≤n,q≤105 ) — the number of integers and the number of queries.
The next line contains n integers a1,a2,…,an ( −105≤ai≤105 ) — the numbers.
Each of the next q lines contains a character and an integer si,xi . ( s_i \in \{<, >\}, -10^5 \leq x_i \leq 10^5 ) – the queries.
输出格式
Print n integers c1,c2,…,cn representing the array after all operations.
输入输出样例
输入#1
11 3 -5 -4 -3 -2 -1 0 1 2 3 4 5 > 2 > -4 < 5
输出#1
5 4 -3 -2 -1 0 1 2 -3 4 5
输入#2
5 5 0 1 -2 -1 2 < -2 < -1 < 0 < 1 < 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]
- >2 : [−5,−4,−3,−2,−1,0,1,2,−3,−4,−5]
- >−4 : [−5,−4,3,2,1,0,−1,−2,3,−4,−5]
- <5 : [5,4,−3,−2,−1,0,1,2,−3,4,5]