fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,x,l=1,a[100000],b[100000],d=0;
  6. cin>>n;
  7. set<long long int> mys;
  8. pair<int,int> apair;
  9. vector<pair<int,int> > v_temp;
  10. for(int i=1;i<=n;i++)
  11. {
  12. cin>>x;
  13. if(mys.empty())
  14. {
  15. l=i;
  16. }
  17. if(mys.find(x)!=mys.end())
  18. {
  19. mys.clear();
  20. d++;
  21. apair.first = l;
  22. apair.second = i;
  23. v_temp.push_back(apair);
  24. }
  25. else
  26. {
  27.  
  28. mys.insert(x);
  29. if(i==n&&d==0)
  30. cout<<"-1"<<endl;
  31. }
  32.  
  33. }
  34. if(d)
  35. cout<<d<<endl;
  36.  
  37.  
  38. for (vector<pair<int,int> >::iterator it2 = v_temp.begin(); it2 != v_temp.end(); ++it2) {
  39. apair = *it2;
  40. cout<< apair.first << " " << apair.second <<endl;
  41. }
  42. return 0;
  43.  
  44.  
  45. }
Success #stdin #stdout 0s 2868KB
stdin
10
933677171 80672280 80672280 933677171 933677171 933677171 933677171 80672280 80672280 933677171
stdout
4
1 3
4 5
6 7
8 9