RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 COCI00698

Crtež

설명

A game is given on a sequence of length \(N\), initially filled with zeros. During the
game, we color positions in the sequence using a series of operations, and we can
stop coloring after any operation.
The \(X\)-th coloring operation is described by the following procedure:
• We select a position containing 0.
• We decide whether to:
– Paint the selected position with - 1.
– Paint the selected position with color \(X\) and continue painting adjacent
positions to the left with color \(X\). We stop painting when we encounter
a position with a value different than 0 (which we do not paint) or when
we go out of the sequence bounds.
Two games are considered equivalent if, in their final sequences, we can rename the colors greater than 0,
i.e., if there is a bijective mapping such that:
• Colors after mapping remain greater than 0.
• Each color receives exactly one new label.
• After mapping, both sequences are identical.
An example of equivalent games is:
• [1, 1, −1, 2, −1, 3, 0]
• [3, 3, −1, 1, −1, 2, 0]
because there is a mapping of colors (color 1 to color 3, color 2 to color 1, color 3 to color 2) such that all
the above conditions are satisfied.
There are \(Q\) updates given, where for each update, we swap all 0s with - 1s and all - 1s with 0s in the
interval [L, R] in the sequence.
After each update, print the number \(K\), the number of different games that can be played with an arbitrary
number of operations such that no two games are equivalent. Since \(K\) is very large, print the result
modulo \(10^{9} + 7\).

제약
입력 형식

In the first line, there are 2 natural numbers \(N\), \(Q\) (\(1 \le N \le 10^{18}\), \(1 \le Q \le 10^{5}\)), representing the number
of fields in the sequence and the number of updates.
In the following \(Q\) lines, there are two natural numbers, \(L\) and \(R\) (\(1 \le L\), \(R \le N\)), indicating the positions
that describe the update from the problem statement.

출력 형식

In the \(i\)-th of the following \(Q\) lines, print the remainder of the division of the number \(K\) by \(10^{9} + 7\) after
each update.

서브태스크
서브태스크점수설명

1

20점

N, \(Q \le 1000\)

2

55점

\(N \le 10^{6}\)

3

45점

No additional constraints.

예제 1
입력
1 2
1 1
1 1
출력
1
3
예제 2
입력
3 2
2 2
1 3
출력
9
3
예제 3
입력
57 2
13 39
6 42
출력
130653412
804077942
설명

Clarification of the first example: After the first update, the sequence is equal to [−1]. We cannot
perform any operations on it, so the maximum number of games we can play is 1. After the second
update, the sequence is equal to [0]. From the sequence [0], using the operations described in the problem
statement, we can create the sequences [0], [1], and [−1]. We observe that no pair of these sequences is
equivalent, so the maximum number of games we can play is 3.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2024/2025 Contest 5

평가 및 의견

Crtež

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Crtež

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8