求助!!
  • 板块学术版
  • 楼主Gao_l
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/8/20 11:59
  • 上次更新2023/10/27 14:28:20
查看原帖
求助!!
750728
Gao_l楼主2022/8/20 11:59

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

求助!!

2022/8/20 11:59
加载中...