其他分享
首页 > 其他分享> > 10.1-10.7

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;
}
View Code

 

标签:10.1,tmp,10.7,maxer,int,max,rep,dot
来源: https://www.cnblogs.com/lxzl/p/13768652.html