https://www.luogu.com.cn/problem/CF1454B
?题目在这
?代码在这
#include<bits/stdc++.h>
using namespace std;
const int N=1e9+5,A=2e5+5;
struct node{
int id,t;
};
int main(){
int t,n;
cin >> t;
while(t--){
cin >> n;a
int MIN=N,MAX=-N;
node a[A]={0};
for(int i=1;i<=n;i++){
int x;
cin >> x;
a[x].t++;
a[x].id=i;
MIN=min(MIN,x),MAX=max(MAX,x);
}
bool f=false;
for(int i=MIN;i<=MAX;i++){
if(a[i].t==1){
cout << a[i].id << "\n";
f=true;
break;
}
}
if(f==false){
cout << -1 << "\n";
}
}
return 0;
}
求助!!