B. Box
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Permutation pp is a sequence of integers p=[p1,p2,…,pn]p=[p1,p2,…,pn], consisting of nn distinct (unique) positive integers between 11 and nn, inclusive. For example, the following sequences are permutations: [3,4,1,2][3,4,1,2], [1][1], [1,2][1,2]. The following sequences are not permutations: [0][0], [1,2,1][1,2,1], [2,3][2,3], [0,1,2][0,1,2].
The important key is in the locked box that you need to open. To open the box you need to enter secret code. Secret code is a permutation pp of length nn.
You don't know this permutation, you only know the array qq of prefix maximums of this permutation. Formally:
You want to construct any possible suitable permutation (i.e. any such permutation, that calculated qq for this permutation is equal to the given array).
Input
The first line contains integer number tt (1≤t≤1041≤t≤104) — the number of test cases in the input. Then tt test cases follow.
The first line of a test case contains one integer nn (1≤n≤105)(1≤n≤105) — the number of elements in the secret code permutation pp.
The second line of a test case contains nn integers q1,q2,…,qnq1,q2,…,qn (1≤qi≤n)(1≤qi≤n) — elements of the array qq for secret permutation. It is guaranteed that qi≤qi+1qi≤qi+1 for all ii (1≤i The sum of all values nn over all the test cases in the input doesn't exceed 105105. Output For each test case, print: Example input Copy output Copy Note In the first test case of the example answer [1,3,4,5,2][1,3,4,5,2] is the only possible answer: It can be proved that there are no answers for the second test case of the example. \========================================================================= 模拟一下,放个队列即可,每当a值不等于上一个a值,那就说明了这个位置已经确定,一旦我们遇到一个确定位置,就把上一个位置到本位置之间的数字全部加入队列,这就是小于本位置的全部可能,当该取出数字的时候队列为空则是无解
4
5
1 3 4 5 5
4
1 1 3 4
2
2 2
1
1
1 3 4 5 2
-1
2 1
1
软件的开发模型
iOS 内购(In-App Purchase)详解
【英雄哥七月集训】第 27天:图
ssl/tls 自签证书
MySQL数据库基础
装饰模式Decorator
【从零开始学习Redis | 第五篇】基于布隆过滤器解决Redis的穿透问题
Pytorch知识点学习
【解锁未来】探索Web3的无限可能性-01
Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
MySQL-Seconds_behind_master的精度误差
[MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
Agent OS :五种驯服不确定性的范式
PortSwigger SQL注入LAB11
数据库即时编译JIT
[Begin]AI Learn Data Day 0
深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU