QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 128 MB مجموع النقاط: 100

#7487. The One Who Never Returns and the People Who Long for Them

الإحصائيات

Chtholly has given you a sequence. You need to support point updates and queries for the shortest length of a subarray whose bitwise OR sum is greater than or equal to a given number. If no such subarray exists, output $-1$.

Input

The first line contains two integers $n$ and $m$.

The next line contains $n$ integers, representing the sequence $a$.

The next $m$ lines are in the following format:

  • $1\ i\ x$: Update $a_i$ to $x$.
  • $2\ k$: Query the shortest length of a subarray whose bitwise OR sum is $\geq k$.

Output

For each operation of type $2$, output a single integer representing the answer. If no such subarray exists, output $-1$.

Examples

Input 1

2 3
0 2 
2 3
1 1 1
2 3

Output 1

-1
2

Note

Idea: kczno1

Solution: kczno1 ($O( m\sqrt n\log a )$ solution), liu_cheng_ao ($O( m\log^2 n\log^2 a )$ solution), 142857cs ($O( m\log n\log^2 a )$ solution)

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

Data: kczno1

For $100\%$ of the data, $0\leq a_i,k\leq 2^{30}$, $1\leq n,m\leq 5\times 10^4$.

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.