fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5.  
  6. void solve() {
  7. int n;
  8. cin >> n;
  9. vector<int> a(n);
  10. for(int i=0;i<n;i++) cin >> a[i];
  11. if(n==2){
  12. cout << 2 << '\n';
  13. cout << 1 << " " << 1 << '\n';
  14. cout << 2 << " " << 2 << '\n';
  15. return;
  16. }
  17. if(n%2==0){
  18. cout << 4 << '\n';
  19. cout << 1 << " " << 1 << '\n';
  20. cout << n << " " << n << '\n';
  21. cout << 2 << " " << n-1 << '\n';
  22. cout << 1 << " " << n << '\n';
  23. return;
  24. }
  25. else{
  26. cout << 3 << '\n';
  27. cout << 1 << " " << 1 << '\n';
  28. cout << 2 << " " << n << '\n';
  29. cout << 1 << " " << n << '\n';
  30. return;
  31. }
  32. }
  33.  
  34. int main(){
  35. ios::sync_with_stdio(false);
  36. cin.tie(nullptr);
  37.  
  38. int t;
  39. cin >> t;
  40. while (t--) solve();
  41.  
  42.  
  43. return 0;
  44. }
  45.  
Success #stdin #stdout 0.01s 5324KB
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
4
1 1
4 4
2 3
1 4
4
1 1
8 8
2 7
1 8
4
1 1
6 6
2 5
1 6
3
1 1
2 5
1 5
3
1 1
2 7
1 7
3
1 1
2 3
1 3