#P15585. [KTSC 2026] 绝妙区间 2 / Wonderful Interval 2
[KTSC 2026] 绝妙区间 2 / Wonderful Interval 2
Problem Description
Youngwoo has two arrays of length . For any , we have .
An interval is a wonderful interval if and only if it satisfies all of the following conditions:
- are integers.
- .
- By repeatedly performing the following operation, can be transformed into :
- Let the current array be .
- Choose two distinct integers () such that , and then set .
Youngwoo is curious about which intervals are wonderful intervals. Specifically, Youngwoo is given queries, numbered , represented by two arrays of length .
Query () asks whether the interval is a wonderful interval.
Write a program to answer Youngwoo’s queries.
Implementation Details
This is a functional interactive problem. You do not need to, and should not, implement the main function.
You should implement the following function:
vector<int> array_operation(vector<int> A, vector<int> B, vector<int> L, vector<int> R)
- : integer arrays of size .
- : integer arrays of size .
- Return an integer array of size . If is a wonderful interval, then should be , otherwise ().
- This function is called exactly once.
Your source code should not call any input/output functions.
Input Format
The input format of the sample grader is as follows:
- Line :
- For all :
- Line :
- For all :
- Line :
Output Format
The sample grader prints the answer in the following format:
- Line : the return value of
array_operation
4 3
2 2
1 1
1 3
2 3
0 1
0 3
1 3
1 1 0
5 5
1 2
2 3
1 1
2 4
1 2
0 2
0 4
1 3
1 4
2 3
1 1 0 1 0
Hint
Constraints
- .
- ().
- ().
Subtasks
| ID | Score | Constraints |
|---|---|---|
| , | ||
| , | ||
| No additional constraints |
Samples
Sample 1
Consider the following call:
array_operation([2, 1, 1, 2], [2, 1, 3, 3], [0, 0, 1], [1, 3, 3])
- [, ] is a wonderful interval. This is because the two arrays , and , are equal.
- [, ] is a wonderful interval. This is because by performing the following operations, [, , , ] can be changed into [, , , ].
- Choose , and perform the operation. After the operation, the array becomes [, , , ].
- Choose , and perform the operation. After the operation, the array becomes [, , , ].
- Choose , and perform the operation. After the operation, the array becomes [, , , ].
- [, ] is not a wonderful interval. It can be proven that no matter how you perform the operations, it is impossible to change [, , ] into [, , ].
Therefore, the function should return [, , ].
Sample 2
Consider the following call:
array_operation([1, 2, 1, 2, 1], [2, 3, 1, 4, 2], [0, 0, 1, 1, 2], [2, 4, 3, 4, 3])
Among all intervals, the wonderful intervals are [, ], [, ], [, ], [, ], [, ]. Therefore, the function should return [, , , , ].
Translated by ChatGPT 5