题意描述
思路
AC代码
代码语言:javascript
复制#include<bits/stdc .h>
#define x first
#define y second
#define PB push_back
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define rep(x,l,u) for(ll x=l;x<u;x )
#define rrep(x,l,u) for(ll x=l;x>=u;x--)
#define sz(x) x.size()
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef pair<char,char> PCC;
typedef long long ll;
const int N=3*1e5 10;
const int M=1e6 10;
const int INF=0x3f3f3f3f;
const int MOD=1e9 7;
/*注意边界
清空每个case的影响
注意数据范围
注意证明*/
ll res[N];
vector<int> p[N];
void solve(){
int n;cin>>n;
rep(i,1,n 1) p[i].clear(),res[i]=INF;
rep(i,1,n 1){
int x;cin>>x;
p[x].PB(i);
}
rep(i,1,n 1){
p[i].PB(n 1);
int mx=-1,last=0;
rep(j,0,sz(p[i])){
mx=max(mx,p[i][j]-last);
last=p[i][j];
}
res[mx]=min(res[mx],i);
}
rep(i,2,n 1) res[i]=min(res[i-1],res[i]);
rep(i,1,n 1) res[i]==INF ? cout<<-1<<' ' : cout<<res[i]<<' ';
cout<<endl;
}
int main(){
IOS;
int t;cin>>t;
while(t--){
solve();
}
return 0;
}