luogu#P5065. [Ynoi Easy Round 2014] 不归之人与望眼欲穿的人们

[Ynoi Easy Round 2014] 不归之人与望眼欲穿的人们

Background

【The First Fleet has sent a message】
【It is about the battle result of Floating Island No. 15】
【The defense operation of Floating Island No. 15...】
【Has failed...】





Problem Description

Chtholly gives you a sequence. It supports point updates, and queries asking for the minimum possible length of an interval whose bitwise OR sum is greater than or equal to a given number. If there is no solution, output 1-1.

Input Format

The first line contains two integers n,mn, m.

The next line contains nn integers, representing the sequence aa.

The next mm lines are in one of the following forms:

  • 1 i x1\ i\ x: set aia_i to xx.
  • 2 k2\ k: query the minimum length such that there exists an interval of that length whose bitwise OR sum is k\geq k.

Output Format

For every operation of type 22, output one line containing an integer, the answer. If there is no solution, output 1-1.

2 3
0 2 
2 3
1 1 1
2 3
-1
2

Hint

Idea: kczno1.

Solution: kczno1 (O(mnloga)O( m\sqrt n\log a ) solution), liu_cheng_ao (O(mlog2nlog2a)O( m\log^2 n\log^2 a ) solution), 142857cs (O(mlognlog2a)O( m\log n\log^2 a ) solution).

Code: kczno1 (O(mnloga)O( m\sqrt n\log a ) code), liu_cheng_ao (O(mlog2nlog2aO( m\log^2 n\log^2a ) code).

Data: kczno1.

Constraints: For 100%100\% of the testdata, 0ai,k2300\leq a_i, k\leq 2^{30}, 1n,m5×1041\leq n, m\leq 5\times 10^4.

Translated by ChatGPT 5