AcWing 4500. 三个元素
原题链接
简单
作者:
志明也要学算法
,
2024-04-06 15:13:19
,
所有人可见
,
阅读 2
#include <iostream>
#include <set>
using namespace std;
const int N = 1e9 + 10;
bool vis[N];
int main(){
set<pair<int,int>> st;
int n;
cin >> n;
for (int i = 1;i <= n;i ++){
int x;
cin >> x;
st.insert(pair<int,int>(x,i));
}
int ans = 0;
int q[3];
for (auto x : st){
if (!vis[x.first]){
q[ans] = x.second;
ans ++;
if (ans == 3) break;
}
vis[x.first] = true;
}
if (q[2] != 0) cout << q[0] << ' ' << q[1] << ' ' << q[2] << endl;
else cout << "-1 -1 -1" << endl;
return 0;
}