-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathD_Find_the_Different_Ones.cpp
73 lines (72 loc) · 1.22 KB
/
D_Find_the_Different_Ones.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef unordered_map<ll, ll> mpp;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define fr(i, a, b) for (int i = a; i < b; i++)
void wushangclan()
{
int n;
cin >> n;
vi v(n);
fr(i, 0, n)
{
cin >> v[i];
}
int q;
cin >> q;
set<int> s;
vi t(n);
int ans=0;
fr(i, 1, n)
{
if (v[i] == v[i - 1])
{
ans++;
continue;
}
else
{
s.insert(i + 1);
}
}
unordered_map<int,int> mp;
fr(i, 0, q)
{
int l, r;
cin >> l >> r;
auto it = s.upper_bound(r);
if (it == s.begin())
{
mp[l]=0;
cout << -1 << " " << -1 << endl;
continue;
}
it--;
if (*it - 1 < l)
{
cout << -1 << " " << -1 << endl;
}
else
{
cout << *it - 1 << " " << *it << endl;
}
}
cout << endl;
}
int main()
{
int t;
cin >> t;
while (t--)
{
wushangclan();
}
return 0;
}