CF1794C.Scoring Subsequences
普及-
通过率:0%
时间限制:2.50s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The score of a sequence [s1,s2,…,sd] is defined as d!s1⋅s2⋅…⋅sd, where d!=1⋅2⋅…⋅d. In particular, the score of an empty sequence is 1.
For a sequence [s1,s2,…,sd], let m be the maximum score among all its subsequences. Its cost is defined as the maximum length of a subsequence with a score of m.
You are given a non-decreasing sequence [a1,a2,…,an] of integers of length n. In other words, the condition a1≤a2≤…≤an is satisfied. For each k=1,2,…,n, find the cost of the sequence [a1,a2,…,ak].
A sequence x is a subsequence of a sequence y if x can be obtained from y by deletion of several (possibly, zero or all) elements.
序列 [s1,s2,…,sd] 的得分定义为 d!s1⋅s2⋅…⋅sd,其中 d!=1⋅2⋅…⋅d。特别地,空序列的得分为 1。
对于序列 [s1,s2,…,sd],设 m 为其所有子序列中得分的最大值,则该序列的代价定义为:所有得分等于 m 的子序列中的最大长度。
给定一个长度为 n 的非递减整数序列 [a1,a2,…,an],即满足 a1≤a2≤…≤an。对每个 k=1,2,…,n,求序列 [a1,a2,…,ak] 的代价。
若序列 x 可通过从序列 y 中删除若干(可能为零个或全部)元素得到,则称 x 是 y 的一个子序列。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains an integer n (1≤n≤105) — the length of the given sequence.
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤n) — the given sequence. It is guaranteed that its elements are in non-decreasing order.
It is guaranteed that the sum of n over all test cases does not exceed 5⋅105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤105)—— 给定序列的长度。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤n)—— 给定序列。保证其元素按非递减顺序排列。
保证所有测试用例的 n 之和不超过 5⋅105。
输出格式
For each test case, output n integers — the costs of sequences [a1,a2,…,ak] in ascending order of k.
对于每个测试用例,输出 n 个整数——即序列 [a1,a2,…,ak] 的代价,按 k 的升序排列。
输入输出样例
输入#1
3 3 1 2 3 2 1 1 5 5 5 5 5 5
输出#1
1 1 2 1 1 1 2 3 4 5
说明/提示
In the first test case:
- The maximum score among the subsequences of [1] is 1. The subsequences [1] and [] (the empty sequence) are the only ones with this score. Thus, the cost of [1] is 1.
- The maximum score among the subsequences of [1,2] is 2. The only subsequence with this score is [2]. Thus, the cost of [1,2] is 1.
- The maximum score among the subsequences of [1,2,3] is 3. The subsequences [2,3] and [3] are the only ones with this score. Thus, the cost of [1,2,3] is 2.
Therefore, the answer to this case is 112, which are the costs of [1],[1,2] and [1,2,3] in this order.
在第一个测试用例中:
- 子序列 [1] 的子序列中最大得分为 1。只有子序列 [1] 和 [](空序列)具有该得分。因此,[1] 的代价为 1。
- 子序列 [1,2] 的子序列中最大得分为 2。唯一具有该得分的子序列是 [2]。因此,[1,2] 的代价为 1。
- 子序列 [1,2,3] 的子序列中最大得分为 3。只有子序列 [2,3] 和 [3] 具有该得分。因此,[1,2,3] 的代价为 2。
因此,本测试用例的答案为 112,即按顺序给出的 [1]、[1,2] 和 [1,2,3] 的代价。
输入解题思路,AI测评打分。不知道怎么写?