#P9061. [Ynoi2002] Optimal Ordered Problem Solver
[Ynoi2002] Optimal Ordered Problem Solver
Problem Description
Given points , you need to process operations in order. Each operation gives .
- First, perform an update:
- If , then for all points satisfying , set their to .
- If , then for all points satisfying , set their to .
- Then perform a query: ask for the number of points satisfying .
Input Format
The first line contains two integers .
The next lines each contain two integers .
The next lines each contain five integers , representing one operation.
Output Format
Output lines, each containing one integer. In order, output the answer to the query in each operation.
5 6
1 2
3 1
5 1
3 5
4 4
1 4 2 5 4
1 4 3 5 3
2 3 5 1 3
2 2 3 1 4
1 3 3 1 4
2 5 5 2 1
4
3
0
0
0
0
Hint
Idea: ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078.
Constraints: For all testdata, , and .
Subtask 1 (20 points): .
Subtask 2 (20 points): are independently chosen uniformly at random from to .
Subtask 3 (20 points): .
Subtask 4 (20 points): , depends on Subtask 1.
Subtask 5 (20 points): No special restrictions, depends on Subtasks 1, 2, 3, 4.
Translated by ChatGPT 5