10.1-10.7
cf1417c
#include<bits/stdc++.h> using namespace std; #define rep(i,h,t) for (int i=h;i<=t;i++) #define dep(i,t,h) for (int i=t;i>=h;i--) int t; const int N=3e5+222; int a[N],n; vector<int>b[N]; int tmp; int main(){ // freopen("p.in","r",stdin); // freopen("p.out","w",stdout); cin>>t; rep(numx,1,t){ cin>>n; rep(i,1,n)a[i]=-1; rep(i,1,n){ int dot; cin>>dot; b[dot].push_back(i); } tmp=n; rep(i,1,n){ if(b[i].size()==0)continue; int maxer=0; int dot=b[i].size(); rep(k,0,dot-2) maxer=max(maxer,b[i][k+1]-b[i][k]); maxer=max(maxer,b[i][0]); maxer=max(maxer,n-b[i][dot-1]+1); while(tmp>=maxer){a[tmp]=i;tmp--;} //cout<<maxer<<endl; } rep(i,1,n)cout<<a[i]<<' '; cout<<endl; rep(i,1,n)b[i].clear(); } return 0; }
戒骄戒躁