#P17270. [eJOI 2026] Increasing Split

    ID: 19747 远端评测题 1500ms 1024MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>动态规划 DP交互题Special JudgeeJOI(欧洲)背包 DP图论建模二分图2026bitset

[eJOI 2026] Increasing Split

Problem Description

Boris and Ihor have found a sequence aa of NN positive integers, a0,a1,,aN1a_0,a_1,\ldots,a_{N-1}, and want to split it between themselves. Unable to agree on the split, they have asked you to act as their arbiter.

Before making any decisions, you are shown the entire sequence. You then process the elements of aa from left to right: first a0a_0, then a1a_1, and so on up to aN1a_{N-1}. As each element is processed, you must give it to exactly one of Boris and Ihor.

Both insist that the elements they receive form a strictly increasing sequence in the order received. Every element you give to a person must be strictly greater than the previous element given to that same person. The first element a person receives may have any value, and one person may receive no elements at all.

For every integer KK from 00 to NN, determine whether it is possible to split the elements so that Boris receives exactly KK elements and both resulting sequences are strictly increasing. Treat every value of KK as an independent question.

For example, let a=[3,1,4,5,5]a=[3,1,4,5,5].

  • For K=3K=3, give a0=3a_0=3, a2=4a_2=4, and a3=5a_3=5 to Boris, and give a1=1a_1=1 and a4=5a_4=5 to Ihor. Boris receives 3,4,53,4,5 and Ihor receives 1,51,5; both sequences are strictly increasing, so K=3K=3 is possible.
  • For K=0K=0, Boris receives nothing and Ihor receives everything. Ihor's sequence begins with 3,13,1, so it is not strictly increasing and K=0K=0 is impossible.

For this example, the only possible values of KK are 22 and 33.

Implementation details

Implement the following function:

std::vector<bool> increasing_split(std::vector<int> a)
  • aa: the sequence of NN numbers.

The function must return a boolean array of size exactly N+1N+1. Its element at index ii must be true if the elements can be split so that Boris receives exactly ii elements and both resulting sequences are strictly increasing, and false otherwise. The function is called exactly once per test.

Input Format

Input format:

  • line 11: one integer NN;
  • line 22: NN integers a0,a1,,aN1a_0,a_1,\ldots,a_{N-1}.

Output Format

If the returned array does not have size N+1N+1, the sample grader prints WA: Returned array does not have size N+1. Otherwise, it prints a binary string of length N+1N+1 whose character at index ii is 1 if K=iK=i is possible, and 0 otherwise.

5
3 1 4 5 5
001100
4
1 2 3 4
11111

Hint

Explanation of example 1

Here a=[3,1,4,5,5]a=[3,1,4,5,5]. For each KK:

  • K=0K=0: no valid split exists, so the answer is 0;
  • K=1K=1: no valid split exists in which Boris receives exactly one element, so the answer is 0;
  • K=2K=2: give a1=1a_1=1 and a4=5a_4=5 to Boris, and a0=3a_0=3, a2=4a_2=4, and a3=5a_3=5 to Ihor. Both sequences are strictly increasing, so the answer is 1;
  • K=3K=3: a valid split exists as described above, so the answer is 1;
  • K=4K=4 and K=5K=5: no valid split exists, so both answers are 0.

Explanation of example 2

Here a=[1,2,3,4]a=[1,2,3,4] is already strictly increasing. Regardless of how the elements are split, both people receive strictly increasing sequences. Hence every KK from 00 to 44 is possible.

Constraints

  • 2N41052\le N\le 4\cdot 10^5
  • 1ai1091\le a_i\le 10^9 for every 0i<N0\le i<N

Subtasks

Subtask Points NN Additional constraints
0 - The examples.
1 10 N18N\le 18 -
2 5 N4105N\le 4\cdot 10^5 aiai+1a_i\le a_{i+1} for every 0i<N10\le i<N-1.
3 a0max(a1,a2,,aN1)a_0\ge \max(a_1,a_2,\ldots,a_{N-1}).
4 16 aa is a permutation of 1,,N1,\ldots,N. For every 0i<N10\le i<N-1 such that ai<ai+1a_i<a_{i+1}, the prefix a0,,aia_0,\ldots,a_i is a permutation of 1,,i+11,\ldots,i+1.
5 21 N5000N\le 5000 aa is a permutation of 1,,N1,\ldots,N. For every 0i<N10\le i<N-1 such that max(a0,,ai)<ai+1\max(a_0,\ldots,a_i)<a_{i+1}, the prefix a0,,aia_0,\ldots,a_i is a permutation of 1,,i+11,\ldots,i+1.
6 17 N4105N\le 4\cdot 10^5
7 16 N5000N\le 5000 -
8 10 N4105N\le 4\cdot 10^5