fork(3) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int tc;
  5. int N, A[200005];
  6. int lol[200005][2];
  7. map<int, int> cnt;
  8. bool yes;
  9.  
  10. int main() {
  11. scanf("%d", &tc);
  12. while(tc--) {
  13. scanf("%d", &N);
  14. int mx = 0;
  15. for(int i = 1; i <= N; i++) {
  16. scanf("%d", &A[i]);
  17. }
  18. for(int i = 1; i <= N; i++) {
  19. if(!cnt.count(A[i])) {
  20. cnt[A[i]] = 1;
  21. mx = max(A[i], mx);
  22. if(mx == i) lol[i][0] = 1;
  23. }else break;
  24. }
  25. cnt.clear();
  26. mx = 0;
  27. for(int i = N; i > 0; i--) {
  28. if(!cnt.count(A[i])) {
  29. cnt[A[i]] = 1;
  30. mx = max(A[i], mx);
  31. if(mx == N - i + 1) lol[i][1] = 1;
  32. }else break;
  33. }
  34. cnt.clear();
  35. int ans = 0;
  36. for(int i = 2; i <= N; i++) {
  37. if(lol[i - 1][0] && lol[i][1]) {
  38. ans++;
  39. }
  40. }
  41. cout << ans << "\n";
  42. for(int i = 2; i <= N; i++) {
  43. if(lol[i - 1][0] && lol[i][1]) {
  44. cout << i - 1 << " " << N - i + 1 << "\n";
  45. }
  46. lol[i - 1][0] = 0;
  47. lol[i - 1][1] = 0;
  48. lol[i][1] = 0;
  49. }
  50. lol[N][0] = 0;
  51. }
  52. return 0;
  53. }
Success #stdin #stdout 0s 4528KB
stdin
1
12
2 1 3 4 5 6 7 8 9 1 10 2
stdout
1
2 10