-
Notifications
You must be signed in to change notification settings - Fork 0
/
C.cpp
49 lines (47 loc) · 924 Bytes
/
C.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
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
long long ara[300005],l[300005],r[300005];
int main()
{
fastio;
long long n,i,p=0,c=0;
cin>>n;
for(i=0;i<n;i++)
cin>>ara[i];
set<long long, greater<long long> > s;
for(i=0;i<n;i++)
{
if(s.count(ara[i])==0)
{
s.insert(ara[i]);
if(i==n-1)
r[c-1]=i+1;
}
else
{
if(p==0)
{
p=1;
l[0]=1;
r[0]=i+1;
}
else
{
l[c]=r[c-1]+1;
r[c]=i+1;
}
c++;
s.clear();
}
}
if(p==0)
cout<<-1<<"\n";
else
{
cout<<c<<"\n";
for(i=0;i<c;i++)
cout<<l[i]<<" "<<r[i]<<"\n";
}
return 0;
}