-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1330B.cpp
132 lines (124 loc) · 2.16 KB
/
1330B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <bits/stdc++.h>
#include <map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define show(x) cerr<<(#x)<<" : "<<x<<endl;
#define ll long long
#define ld long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"
const ll MOD = 1000*1000*1000+7;
const ll MOD2 = 998244353;
const ll N = 1000*1000+5;
const double PI = 3.14159265;
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main(){
fastio();
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n+1];
int h1[200005]={0};
for(int i=1;i<=n;i++){
cin>>a[i];
h1[a[i]]++;
}
int flag=0;
// for(int i=1;i<(n+1)/2;i++){
// if(h1[i]<2||h1[i]>2){
// flag=1;
// break;
// }
// }
// if(flag==1){
// cout<<0<<endl;
// continue;
// }
vector<pair<int,int> > ans;
int h2[200005]={0};
int i=1;
map<int,int> x,y;
while(i<=n){
h2[a[i]]++;
if(h2[a[i]]>=2)
break;
x[a[i]]++;
i++;
}
int j=i-1;
while(i<=n){
y[a[i]]++;
i++;
}
i=1;
for(auto it=x.begin();it!=x.end();it++){
if(it->ff!=i||it->ss>=2){
flag=1;
break;
}
i++;
}
i=1;
for(auto it=y.begin();it!=y.end();it++){
if(it->ff!=i||it->ss>=2){
flag=1;
break;
}
i++;
}
if(flag==0&&j!=n&&j!=0){
ans.pb(mp(j,(n-j)));
}
flag=0;
x.clear();
y.clear();
i=n;
int h3[200005]={0};
while(i>0){
h3[a[i]]++;
if(h3[a[i]]>=2)
break;
x[a[i]]++;
i--;
}
j=i;
while(i>0){
y[a[i]]++;
i--;
}
i=1;
for(auto it=x.begin();it!=x.end();it++){
if(it->ff!=i||it->ss>=2){
flag=1;
break;
}
i++;
}
i=1;
for(auto it=y.begin();it!=y.end();it++){
if(it->ff!=i||it->ss>=2){
flag=1;
break;
}
i++;
}
// cout<<"check"<<endl;
if(flag==0&&j!=n&&j!=0){
if(ans.size()==0||j!=ans[0].ff)
ans.pb(mp(j,(n-j)));
}
cout<<ans.size()<<endl;
for(int i=0;i<ans.size();i++){
cout<<ans[i].ff<<' '<<ans[i].ss<<endl;
}
}
}