QOJ.ac

QOJ

時間限制: 5 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#4214. Дежавю

统计

Дан массив $x_1, x_2, \dots, x_n$. Вам необходимо выполнять два типа запросов к этому массиву:

  • Даны $i$ и $y$, присвоить $x_i = y$.
  • Дан $l$, найти наименьшее $d$ среди всех кортежей $(a, b, c, d)$, таких что $l \le a < b < c < d$ и $x_a < x_b < x_c < x_d$, или сообщить, что таких кортежей не существует.

Входные данные

Первая строка содержит два целых числа $n, q$ ($1 \le n, q \le 500\,000$): количество элементов в массиве и количество запросов. Вторая строка содержит $n$ целых чисел $x_1, x_2, \dots, x_n$ ($1 \le x_i \le 10^9$). Каждая из следующих $q$ строк содержит описание запроса. Если первое число в строке равно 1, то следующие два числа — это $i$ и $y$ ($1 \le i \le n, 1 \le y \le 10^9$), описывающие запрос первого типа. В противном случае первое число в строке равно 2, а следующее число равно $l$ ($1 \le l \le n$), описывающее запрос второго типа.

Выходные данные

Для каждого запроса второго типа выведите наименьшее $d$ среди всех кортежей $(a, b, c, d)$, таких что $l \le a < b < c < d$ и $x_a < x_b < x_c < x_d$, или выведите «-1», если таких кортежей не существует.

Примеры

Входные данные 1

11 10
1 2 3 4 5 10 9 8 7 6 8
2 1
1 3 2
2 1
1 1 2
2 1
2 5
2 6
1 9 6
1 10 7
2 5

Выходные данные 1

4
5
6
-1
-1
11

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.