CF(C. Scoring Subsequences)(div2)
迪丽瓦拉
2025-05-28 16:11:41
0次

The score of a sequence [𝑠1,𝑠2,…,𝑠𝑑] is defined as 𝑠1⋅𝑠2⋅…⋅𝑠𝑑𝑑!, where 𝑑!=1⋅2⋅…⋅ In particular, the score of an empty sequence is 1.

For a sequence [𝑠1,𝑠2,…,𝑠𝑑], let 𝑚 be the maximum score among all its subsequences. Its cost is defined as the maximum length of a subsequence with a score of 𝑚

You are given a non-decreasing sequence [𝑎1,𝑎2,…,𝑎𝑛]of integers of length 𝑛. In other words, the condition 𝑎1≤𝑎2≤…≤𝑎𝑛is satisfied. For each 𝑘=1,2,…,𝑛, find the cost of the sequence [𝑎1,𝑎2,…,𝑎𝑘]

A sequence 𝑥 is a subsequence of a sequence 𝑦 if 𝑥 can be obtained from 𝑦 by deletion of several (possibly, zero or all) elements.

Input

Each test contains multiple test cases. The first line contains the number of test cases 𝑡(1≤𝑡≤104 The description of the test cases follows.

The first line of each test case contains an integer 𝑛 (1≤𝑛≤105) — the length of the given sequence.

The second line of each test case contains 𝑛 integers 𝑎1,𝑎2,…,𝑎𝑛 (1≤𝑎𝑖≤𝑛) — the given sequence. It is guaranteed that its elements are in non-decreasing order.

It is guaranteed that the sum of 𝑛 over all test cases does not exceed 5⋅1055⋅105.

Output

For each test case, output 𝑛� integers — the costs of sequences [𝑎1,𝑎2,…,𝑎𝑘] in ascending order of 𝑘

Example

input

Copy

 

3

3

1 2 3

2

1 1

5

5 5 5 5 5

output

Copy

1 1 2 
1 1 
1 2 3 4 5 

Note

In the first test case:

  • The maximum score among the subsequences of [1] is 11. 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.

 

判断当前序列的末尾是否小于序列长度 

#include 
#include 
#include 
#include 
#include 
using namespace std;
constexpr int N=1e5+7;
typedef long long ll;
int a[N];
int main(){int t;scanf("%d",&t);while(t--){int n;cin>>n;for(int i=1;i<=n;i++)cin>>a[i];int l=1,r=1;int len=0;while(r<=n){r++;len++;while(len>1&&a[l]

 

相关内容

热门资讯

AI做攻略、“双向奔赴”……国... 本文转自:人民网人民网记者 许维娜今年国庆假期,AI(人工智能)成了不少年轻人的“旅行搭子”。行前做...
合肥的这个“梗”, 翻篇了 社交平台的评论区,曾长期流传一句专属于合肥的黑色幽默。有人问合肥哪里好玩,本地网友半开玩笑地回复:合...
7万+旅游中高层都在的群,今天... 做旅游这行,资源卡位、渠道互通、项目落地——往往就差一个“对的机会”。我们的行业社群已聚集70,00...
一场帐篷音乐节,如何让井研从“... 帐篷音乐节现场封面新闻记者 周洪攀10月的研溪湿地,晚风里裹着柑橘的清甜与民谣的回响。夜幕降临,10...
白鹤翩翩落星愿,上海迪士尼度假... 10月9日,世界候鸟日前夕,上海迪士尼度假区星愿公园的湖风里多了一分白鹤的灵动。三座白鹤雕塑正式揭幕...
成都锦江边赏初秋枫叶飘飘 目前,成都锦江边国华街枫叶树红了。近年来,国华街附近的几条街都栽种了红枫树,是城区较集中看枫叶的点位...
GBTA:商务旅行正在复苏,但... 亚太正在成为全球商务旅行增长的重要引擎。在经历疫情后的快速反弹之后,全球商务旅行正在进入一个新的增长...
从景区焕新到节赛引流 邹城双节... 齐鲁网·闪电新闻10月9日讯 中秋、国庆“双节”假期,邹城市文化和旅游局提前谋划、周密部署,立足自身...
江山如此多娇 且看石楼今朝 金秋十月,黄河岸畔秋意盎然,丰收盛会喜迎国庆。本次石楼国庆文旅活动以“江山如此多娇,且看石楼今朝”为...
海南国庆假期接待游客475.4... 2026年国庆假期,海南接待游客475.40万人次,较2025年增长13.1%,较2024年增长15...