forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1016Parencodings.cpp
More file actions
46 lines (35 loc) · 1011 Bytes
/
1016Parencodings.cpp
File metadata and controls
46 lines (35 loc) · 1011 Bytes
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
#include <iostream>
using namespace std;
int main(void){
int t,n,i,j;
cin>>t;
while(t--){
cin>>n;
int p,sum=0,count=0;
int* num=new int[2*n];
for(i=0;i<n;i++){
cin>>p;
for(j=0;j<p-sum;j++) num[count++]=1;
num[count++]=0;
sum=p;
}
int total,a;
for(i=0;i<2*n;i++){
while(num[i]!=0) i++;
total=1;
a=1;
for(j=i-1;;j--){
if(num[j]==0){
total++;
a++;
}
else a--;
if(a==0) break;
}
cout<<total;
if(i!=2*n-1) cout<<" ";
}
cout<<endl;
}
return 0;
}