-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathB.cpp
118 lines (109 loc) · 1.79 KB
/
B.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
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int main()
{ quick;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
cin>>t;
while(t--)
{
ll int n;
cin>>n;
//cout<<"n="<<n<<" ";
ll int a[n];
fab(0,n,i)
cin>>a[i];
int freq[200005]={0},freq2[200005]={0};//freq3[200005]={0};
//fab(0,n,i)
//cout<<a[i]<<" ";
ll int su=0,ans=-1;
fab(0,n,i)
{
freq2[a[i]]++;
if(freq2[a[i]]>2)
{ans=0;
break;}
}
fab(0,200005,i)
freq2[i]=0;
ll int sum=0,pmax[n]={0};
ll int max=0;
for(int i=n-1;i>=0;i--)
{
if(a[i]>max)
max=a[i];
pmax[i]=max;
}
vector<int> l1;
fab(0,n,i)
sum+=a[i];
max=0;
ll int las=0;
for(int i=n-1;i>=0;i--)
{
freq2[a[i]]++;
if(freq2[a[i]]>1)
{
las=i;
break;
}
}
//// cout<<"las=ii"<<las<<" ";
max=0;
fab(0,las,i)
{
if(a[i]>max)
max=a[i];
su+=a[i];
freq[a[i]]++;
if(freq[a[i]]>1)
{ ans=0;
break;
}
}
//cout<<"su="<<su<<" "<<ans<<" ";
if(ans==0)
{
cout<<0<<endl;
continue;
}
ans=0;
fab(las,n-1,i)
{
if(a[i]>max)
max=a[i];
su+=a[i];
freq[a[i]]++;
//cout<<"fre"<<freq[a[i]]<<" ";
if(freq[a[i]]>1)
break;
if(su==(max*(max+1)/2))
{
//cout<<"i="<<max<<endl;
if(sum-su==(pmax[i+1]*(pmax[i+1]+1)/2))
{ans++;
l1.pb(i+1);
}
}
}
cout<<ans<<endl;
fab(0,l1.size(),i)
cout<<l1[i]<<" "<<n-l1[i]<<endl;
}
return 0;
}