시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 1024 MB165282520.833%

문제

You are given a binary sequence $a_1, a_2, \ldots, a_n$ of length $n$. You will also be given $q$ queries of two different types.

  1. $p$ $t$: replace $a_p$ with $t$.
  2. $l$ $r$ $x$ $y$: Find any $[s, e]$ satisfying the following conditions, or report that none exists:
    • $l \leq s \leq e \leq r$
    • The longest consecutive number of $0$'s in $a_s, a_{s+1}, \ldots, a_e$ is $x$.
    • The longest consecutive number of $1$'s in $a_s, a_{s+1}, \ldots, a_e$ is $y$.

입력

The first line contains two integers $n$ and $q$ ($1 \leq n, q \leq 2 \times 10^5$).

The second line contains a binary string of length $n$ denoting the binary sequence $a_1a_2 \ldots a_n$.

Followed by $q$ lines, each is in one of the following formats:

  • First type query: $1$ $p$ $t$ ($1 \leq p \leq n, t \in \{0, 1\}$)
  • Second type query: $2$ $l$ $r$ $x$ $y$ ($1 \leq l \leq r \leq n, 0 \leq x, y \leq n$)

출력

For each query of the second type, if there exists a segment $[s, e]$ satisfying the conditions, print two integers $s$ and $e$ separated by a single space. Otherwise, print $-1$.

If there are multiple possible answers, you may print any.

서브태스크

번호배점제한
110

$n, q \leq 100$

220

$n, q \leq 5000$

330

You are only given a query of second type.

440

No further constraints.

예제 입력 1

4 6
0010
2 1 4 1 1
1 3 0
2 1 4 1 1
2 1 4 3 0
1 4 1
2 1 4 3 1

예제 출력 1

2 3
-1
1 3
1 4

예제 입력 2

1 6
1
2 1 1 0 0
2 1 1 1 0
2 1 1 1 1
1 1 0
2 1 1 1 0
2 1 1 0 1

예제 출력 2

-1
-1
-1
1 1
-1

출처

University > KAIST > 2023 KAIST RUN Spring Contest E번

채점 및 기타 정보

  • 예제는 채점하지 않는다.