問題一覧 > 通常問題

No.230 Splarraay スプラレェーイ

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 128
作問者 : koyumeishi
お気に入りにしたユーザー ProblemId : 625 / 自分の提出
問題文最終更新日: 2026-10-19 10:18:28
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 111 (順位表) の他の問題:

Problem Statement

Splarraay スプラレェーイ is a simple game that is just about painting an array.
Players are divided into Team A and Team B, and the teams compete by painting a single array with the color representing their team.
The final score is determined by the sum of the number of elements painted in that team's color and the bonus points described below, and the team with the higher score wins the game.

Rules

  1. An array of length $N$, not painted in any color, is given.
  2. The two teams paint intervals $[l,r]$ of the array with their team's color. If a place being painted is already colored, it is overwritten by the color painted later.
  3. Bonus chances are given at irregular times. In a bonus chance, an interval $[l,r]$ is given. Let $A_{l,r}$ be the number of elements in the interval $[l,r]$ painted by Team A at that moment, and $B_{l,r}$ be the number of elements in the interval $[l,r]$ painted by Team B at that moment. The team with the larger value receives $max(A_{l,r}, B_{l,r})$ bonus points. If $A_{l,r}$ and $B_{l,r}$ are equal, neither team receives bonus points.
  4. When the time limit is reached and the game ends, a team's score is the sum of the number of elements in the whole interval $[0,N-1]$ of the array painted in that team's color and the bonus points it has obtained so far.

The game has already ended, and all that remains is to calculate the scores. The history of each team's actions and the details of the bonus chances are given in chronological order, so compute the final scores.

Input

$N$
$Q$
$x$ $l$ $r$

$N$ The length of the array being painted
$Q$ The sum of the number of actions by the teams and the number of bonus chances. The details of the actions/bonus chances are given in chronological order over the following Q lines
When $x=0$, a bonus chance on the interval $[l,r]$
When $x=1$, a painting action by Team A on the interval $[l,r]$
When $x=2$, a painting action by Team B on the interval $[l,r]$

All input values are integers and satisfy the following constraints
$1\leq N \leq 100,000$
$1\leq Q \leq 100,000$
$0\leq x \leq 2$
$0\leq l \leq r \leq N-1$

Output

Output Team A's score and Team B's score separated by a space. Print a newline at the end.

チームAのスコア チームBのスコア

Sample

Sample 1
Input
5
2
1 0 3
2 2 4
Output
2 3

The array changes as follows.

[-----]
[AAAA-]
[AABBB]

Sample 2
Input
5
3
1 0 4
2 1 3
0 3 4
Output
2 3

The array changes as follows.

[-----]
[AAAAA]
[ABBBA]
[ABBBA] Bonus!
In the bonus chance, $A_{3,4} = B_{3,4} = 1$, so neither team receives bonus points.

Sample 3
Input
6
6
1 1 2
2 4 5
0 2 4
2 0 3
1 1 5
0 0 5
Output
10 1

The array changes as follows.

[------]
[-AA---]
[-AA-BB]
[-AA-BB] Bonus!
[BBBBBB]
[BAAAAA]
[BAAAAA] Bonus! A +5
In the first bonus chance, $A_{2,4} = B_{2,4} = 1$, so neither team receives bonus points.
In the second bonus chance, $A_{0,5} = 5 > B_{0,5} = 1$, so A receives 5 bonus points.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。