fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  5. #define int long long
  6. #define endl '\n'
  7.  
  8. int32_t main(){
  9. fast_io;
  10.  
  11. int t;
  12. cin>>t;
  13.  
  14. while(t--){
  15. int n;
  16. cin>>n;
  17.  
  18. vector<int>a(n);
  19. unordered_map<int,int> f;
  20.  
  21. for(int i=0;i<n;i++){
  22. cin>>a[i];
  23. f[a[i]]++;
  24. }
  25.  
  26. int l=-1,r=-1;
  27. int best=0;
  28.  
  29. int i=0;
  30. while(i<n){
  31. if(f[a[i]]!=1){
  32. i++;
  33. continue;
  34. }
  35.  
  36. int j=i;
  37. while(j<n && f[a[j]]==1) j++;
  38.  
  39. if(j-i>best){
  40. best=j-i;
  41. l=i+1;
  42. r=j;
  43. }
  44.  
  45. i=j;
  46. }
  47.  
  48. if(best==0) cout<<0<<endl;
  49. else cout<<l<<" "<<r<<endl;
  50. }
  51.  
  52. return 0;
  53. }
Success #stdin #stdout 0s 5320KB
stdin
3
1
1
5
1 1 1 1 1
4
2 1 3 2
stdout
1 1
0
2 3