#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 200010;
int a[N];
int cnt[N],f[N];
int res[N],idx=0;
int main()
{
int T;
cin>>T;
while(T--)
{
int idx=0;
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>a[i],cnt[i]=0,f[i]=0;
cnt[0]=f[0]=0;
for(int i=1;i<=n;i++)cnt[a[i]]++;
int p=0,last=0;
for(int i=1;i<=n;i++)
{
f[a[i]]++;
while(f[p])p++;
if(!cnt[p])
{
res[++idx]=p;
for(int j=last+1;j<=i;j++)f[a[j]]=0,cnt[a[j]]--;
last=i;
p=0;
}
}
cout<<idx<<endl;
for(int i=1;i<=idx;i++)cout<<res[i]<<" ";puts("");
}
}
相关文章
- 12-04Codeforces Round #524 (Div. 2) C. Masha and two friends
- 12-04Codeforces Round #394 (Div. 2) C. Dasha and Password 暴力
- 12-0401背包 Codeforces Round #267 (Div. 2) C. George and Job
- 12-04Codeforces Round #648 (Div. 2) F - Swaps Again 思维
- 12-04C. Moamen and XOR[Codeforces Round #737 (Div. 2)]
- 12-04Codeforces Round #379 (Div. 2) C. Anton and Making Potions 二分
- 12-04Codeforces Round #379 (Div. 2) C. Anton and Making Potions —— 二分
- 12-04Codeforces Round #381 (Div. 2)C. Alyona and mex(思维)
- 12-04Codeforces Round #229 (Div. 2) C. Inna and Candy Boxes 树状数组s
- 12-04Codeforces Round #692 (Div. 2)C. Peaceful Rooks(并查集求环数)