Untitled
unknown
plain_text
a year ago
429 B
9
Indexable
#include <bits/stdc++.h>
using namespace std;
int32_t main()
{
int n; cin >> n;
map <int,int> f_occ, s_occ;
for(int i = 0; i < n; i++) {
int x; cin >> x;
if(f_occ.find(x) == f_occ.end()) {
f_occ[x] = i ;
}
s_occ[x] = i + 1 ;
}
int t; cin >> t;
while(t--) {
int n; cin >> n;
if(s_occ[n] == 0) {
cout << -1 << endl;
}
else
cout << f_occ[n] << " " << s_occ[n] << endl;
}
return 0;
}Editor is loading...
Leave a Comment