fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define GG ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  4. int main () { GG;
  5. int t; cin>>t;
  6. while(t--) {
  7. int n,c=0,x,xx; cin>>n;
  8. int a[n],cnt[100010]={0}; bool f=0;
  9. for(int i=0;i<n;i++)
  10. { cin>>a[i];
  11. cnt[a[i]]++;
  12. }
  13.  
  14. for(int i=0;i<100010;i++)
  15. { if(cnt[i]==0)
  16. {x=i; break;
  17. }
  18. }
  19.  
  20. for(int i=0;i<n;i++)
  21. {
  22. cnt[a[i] ]--;
  23. if(a[i]<x) c++;
  24.  
  25. if(c==x)
  26. { xx=i;
  27. break;
  28. }
  29. }
  30.  
  31. for(int i=0;i<x;i++)
  32. { if(cnt[i]==0)
  33. { f=1;
  34. break;
  35. }
  36.  
  37. }
  38.  
  39. if(f) cout<<"-1\n";
  40. else cout<<"2\n"<<"1 "<<xx+1<<"\n"<<xx+2<<" "<<n<<"\n";
  41.  
  42. }return 0;}
Success #stdin #stdout 0.01s 5312KB
stdin
5
2
0 0
5
0 1 2 3 4
8
0 1 7 1 0 1 0 3
3
2 2 2
4
0 1 2 0
stdout
2
1 1
2 2
-1
2
1 2
3 8
2
1 1
2 3
-1