fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t;
  7. cin>>t;
  8. while(t--){
  9. int n,data;
  10. cin>>n;
  11. bool all = true;
  12. for(int i=0;i<n;i++){
  13. cin>>data;
  14. if(data!=0) all = false;
  15. }
  16.  
  17. if(all){
  18. cout<<0<<"\n";
  19. continue;
  20. }
  21.  
  22. if(n&1){
  23. cout<<4<<"\n";
  24. cout<<1<<" "<<n-1<<"\n";
  25. cout<<1<<" "<<n-1<<"\n";
  26. cout<<n-1<<" "<<n<<"\n";
  27. cout<<n-1<<" "<<n<<"\n";
  28. }else{
  29. cout<<2<<"\n";
  30. cout<<1<<" "<<n<<"\n";
  31. cout<<1<<" "<<n<<"\n";
  32. }
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5288KB
stdin
6
4
1 2 3 0
8
3 1 4 1 5 9 2 6
6
1 5 4 1 4 7
5
0 0 0 0 0
7
1 1 9 9 0 1 8
3
100 100 0
stdout
2
1 4
1 4
2
1 8
1 8
2
1 6
1 6
0
4
1 6
1 6
6 7
6 7
4
1 2
1 2
2 3
2 3