QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#323369#4824. Bracket-and-bar Sequenceshotboy27030 4ms3836kbC++143.9kb2024-02-09 12:08:542024-02-09 12:08:54

Judging History

你现在查看的是最新测评结果

  • [2024-02-09 12:08:54]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:3836kb
  • [2024-02-09 12:08:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1LL)
#define MASK(i) (1LL << (i))
ull dp[60];
ll f(ll x,ll y){
    return ll(dp[x] * dp[y]);
}
ll recursion_count = 0;
ll pr_to_int(string s){
//    cout<<s<<endl;
    if ((recursion_count++)>1000){
        assert(0);
        return 0;
    }
    ll n = sz(s)/3;
    if (n < 2)return 0;
    ll sum = 0;
    ll l = -1;
    for (ll i = sz(s) - 1;i >= 0;i --){
        sum += (s[i] == '|' ? 0 : (s[i] == '(' ? 1 : -1));
        if (sum == 0){l = i;break;}
    }
    ll right_sz = (sz(s)-l)/3;
//    cout<<"XXX "<<l<<endl;
    if (right_sz==n){
        ll res = 0;
        for (ll i = 1;i < n;i ++){
            res += f(n - i,i);
        }
        ll sum = 0;
        ll l = -1;
        for (ll i = sz(s) - 2;i >= 0;i --){
            sum += (s[i] == '|' ? 0 : (s[i] == '(' ? 1 : -1));
            if (sum == 0 && s[i] == '|'){l = i;break;}
        }
        l++;
        ll nw_sz = (sz(s) - 1 - l) / 3;
        for (ll i = 0;i < nw_sz;i++){
            res+=f(n-1-i,i);
        }
//        cout<<"SUS "<<s<<' '<<l<<'\n';
        string left_part(s,1,l-2),right_part(s,l,sz(s)-1-l);
//        cout<<"??? "<<left_part<<' '<<right_part<<endl;
        return res + pr_to_int(left_part) * dp[sz(right_part)/3] + pr_to_int(right_part);
    }
    else{
        ll res = 0;
        for (ll i = 1;i < right_sz;i ++){
            res += f(n - i,i);
        }
//        cout<<s<<"SUS"<<l<<' '<<res<<endl;
        string left_part(s,0,sz(s)-right_sz*3),right_part(s,sz(s)-right_sz*3,right_sz*3);
//        cout<<"??? "<<left_part<<' '<<right_part<<endl;
        return res + pr_to_int(left_part) * dp[sz(right_part)/3] + pr_to_int(right_part);
    }
}
ll to_int(string s){
    ll res = 0;
    ll n=sz(s)/3;
    for (ll i = 0;i < n;i++)res+=dp[i];
    res += pr_to_int(s);
    return res;
}
string pr_to_string(ll n,ll k){
    if (n == 1)return "(|)";
    if (n==0)return "";
    for (ll j = 1;j < n;j ++){
        if (f(n-j,j)<=k)k-=f(n-j,j);
        else{
            ll k1,k2;
            k1 = k / dp[j];
            k2 = k % dp[j];
            return pr_to_string(n-j,k1) + pr_to_string(j,k2);
        }
    }
    for (ll i = 0;i < n;i ++){
        if (f(n-1-i,i)<=k)k-=f(n-1-i,i);
        else{
            ll k1,k2;
            k1 = k / dp[i];
            k2 = k % dp[i];
            return "(" + pr_to_string(n-1-i,k1) + "|" + pr_to_string(i,k2) + ")";
        }
    }

}
string too_string(ll x){
    for (ll i = 0;i <= 25;i ++){
        if (x >= dp[i])x -= dp[i];
        else {return pr_to_string(i,x);}
    }
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
    dp[0] = 1;
    dp[1] = 1;
    for (ll i = 1;i <= 25;i ++){
        for (ll j = 0;j <= i;j ++){
            if (j == 0)dp[i+1] += 2 * dp[i];
            else{
                if (j != i)dp[i+j] += dp[i] * dp[j] * 2;
                else dp[i+j] += dp[i] * dp[i];
                if (j != i)dp[i+j+1] += dp[i] * dp[j] * 2;
                else dp[i+j+1] += dp[i] * dp[i];
            }
        }
//        cout<<i<<' '<<dp[i]<<'\n';
    }
    string task;
    cin>>task;
    ll t;
    cin>>t;
    while (t--){
        recursion_count = 0;
        ll n;
        cin>>n;
        if (task=="encode"){
            string s;
            cin>>s;
            cout<<to_int(s)<<'\n';
//            if (recursion_count > 1000){
//                cout<<s<<'\n';
//            }
//            cout<<pr_to_int(s)<<'\n';
        }
        else{
            ll x;
            cin>>x;
            cout<<too_string(x)<<'\n';
        }
    }
}
/*
encode
1
4
(|(|)(|)(|))
decode
3
1
1
4
60
5
225

1274049
1273964
*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3828kb

input:

encode
3
1
(|)
4
((((|)|)|)|)
5
(|(|))((|(|))|)

output:

1
60
225

input:

decode
3
1
1
4
60
5
225

output:

(|)
((((|)|)|)|)
(|(|))((|(|))|)

result:

ok 3 lines

Test #2:

score: 100
Accepted
time: 0ms
memory: 3604kb

input:

encode
1
1
(|)

output:

1

input:

decode
1
1
1

output:

(|)

result:

ok single line: '(|)'

Test #3:

score: 100
Accepted
time: 1ms
memory: 3620kb

input:

encode
3
2
((|)|)
1
(|)
2
(|(|))

output:

3
1
4

input:

decode
3
2
3
1
1
2
4

output:

((|)|)
(|)
(|(|))

result:

ok 3 lines

Test #4:

score: 100
Accepted
time: 1ms
memory: 3820kb

input:

encode
1000
3
(|)(|)(|)
3
(|)(|(|))
3
(|)((|)|)
3
(|(|))(|)
3
(|(|)(|))
3
(|(|(|)))
3
(|((|)|))
3
((|)|)(|)
3
((|)|(|))
3
((|)(|)|)
3
((|(|))|)
3
(((|)|)|)
4
(|)(|)(|)(|)
4
(|)(|)(|(|))
4
(|)(|)((|)|)
4
(|)(|(|))(|)
4
(|)(|(|)(|))
4
(|)(|(|(|)))
4
(|)(|((|)|))
4
(|)((|)|)(|)
4
(|)((|)|(|))
4
(|)((|)...

output:

5
10
9
7
15
17
16
6
14
11
13
12
18
33
32
23
50
52
51
22
49
46
48
47
20
39
38
28
30
29
72
77
76
74
82
84
83
73
81
78
80
79
19
36
35
27
69
71
70
24
26
25
66
68
67
53
58
57
55
63
65
64
54
62
59
61
60
85
154
153
100
201
203
202
99
200
197
199
198
90
169
168
117
119
118
284
289
288
286
294
296
295
285
29...

input:

decode
1000
3
5
3
10
3
9
3
7
3
15
3
17
3
16
3
6
3
14
3
11
3
13
3
12
4
18
4
33
4
32
4
23
4
50
4
52
4
51
4
22
4
49
4
46
4
48
4
47
4
20
4
39
4
38
4
28
4
30
4
29
4
72
4
77
4
76
4
74
4
82
4
84
4
83
4
73
4
81
4
78
4
80
4
79
4
19
4
36
4
35
4
27
4
69
4
71
4
70
4
24
4
26
4
25
4
66
4
68
4
67
4
53
4
58
4
57
4
...

output:

(|)(|)(|)
(|)(|(|))
(|)((|)|)
(|(|))(|)
(|(|)(|))
(|(|(|)))
(|((|)|))
((|)|)(|)
((|)|(|))
((|)(|)|)
((|(|))|)
(((|)|)|)
(|)(|)(|)(|)
(|)(|)(|(|))
(|)(|)((|)|)
(|)(|(|))(|)
(|)(|(|)(|))
(|)(|(|(|)))
(|)(|((|)|))
(|)((|)|)(|)
(|)((|)|(|))
(|)((|)(|)|)
(|)((|(|))|)
(|)(((|)|)|)
(|(|))(|)(|)
(|(|))(|(|)...

result:

ok 1000 lines

Test #5:

score: 100
Accepted
time: 1ms
memory: 3608kb

input:

encode
1000
6
(|((((|)|)|)|)(|))
6
(|((|)(|)(|)|(|)))
6
(|((|)(|(|))|(|)))
6
(|((|)((|)|)|(|)))
6
(|((|(|))(|)|(|)))
6
(|((|(|)(|))|(|)))
6
(|((|(|(|)))|(|)))
6
(|((|((|)|))|(|)))
6
(|(((|)|)(|)|(|)))
6
(|(((|)|(|))|(|)))
6
(|(((|)(|)|)|(|)))
6
(|(((|(|))|)|(|)))
6
(|((((|)|)|)|(|)))
6
(|((|)(|)(|)(...

output:

2434
2671
2676
2675
2673
2681
2683
2682
2672
2680
2677
2679
2678
2604
2619
2618
2609
2636
2638
2637
2608
2635
2632
2634
2633
2606
2625
2624
2614
2616
2615
2658
2663
2662
2660
2668
2670
2669
2659
2667
2664
2666
2665
2605
2622
2621
2613
2655
2657
2656
2610
2612
2611
2652
2654
2653
2639
2644
2643
2641
...

input:

decode
1000
6
2434
6
2671
6
2676
6
2675
6
2673
6
2681
6
2683
6
2682
6
2672
6
2680
6
2677
6
2679
6
2678
6
2604
6
2619
6
2618
6
2609
6
2636
6
2638
6
2637
6
2608
6
2635
6
2632
6
2634
6
2633
6
2606
6
2625
6
2624
6
2614
6
2616
6
2615
6
2658
6
2663
6
2662
6
2660
6
2668
6
2670
6
2669
6
2659
6
2667
6
2664
6...

output:

(|((((|)|)|)|)(|))
(|((|)(|)(|)|(|)))
(|((|)(|(|))|(|)))
(|((|)((|)|)|(|)))
(|((|(|))(|)|(|)))
(|((|(|)(|))|(|)))
(|((|(|(|)))|(|)))
(|((|((|)|))|(|)))
(|(((|)|)(|)|(|)))
(|(((|)|(|))|(|)))
(|(((|)(|)|)|(|)))
(|(((|(|))|)|(|)))
(|((((|)|)|)|(|)))
(|((|)(|)(|)(|)|))
(|((|)(|)(|(|))|))
(|((|)(|)((|)|)...

result:

ok 1000 lines

Test #6:

score: 100
Accepted
time: 1ms
memory: 3552kb

input:

encode
1000
7
((|)(|(|(|)(|)))|(|))
7
((|)(|(|)(|)(|))(|)|)
7
(|(|(|)((|)|))(|(|)))
7
((|(|))|(|))(|(|))(|)
7
(|)((|(|)((|)|)(|))|)
7
(((|(|)(|))|((|)|))|)
7
((|)((|(|))(|(|))|)|)
8
(|)(|)(|(|))((|((|)|))|)
7
((|)|)((|)|)(((|)|)|)
7
(|)((|)|)(((|)|(|))|)
7
(|((|)|(|)))(|(|)(|))
7
((|)|(|(|)((|)|))(|...

output:

13931
11614
15612
3306
10759
13227
12600
44876
6451
7406
7052
14732
33725
3272
15474
16962
4710
6766
17230
14928
15920
4945
12729
12784
13638
8648
5699
5267
12270
10882
5840
15998
4478
5379
16604
12033
12989
4826
13318
11331
7050
10978
5985
16999
16306
15248
4381
16906
8940
16581
13974
8569
14802
37...

input:

decode
1000
7
13931
7
11614
7
15612
7
3306
7
10759
7
13227
7
12600
8
44876
7
6451
7
7406
7
7052
7
14732
8
33725
7
3272
7
15474
7
16962
7
4710
7
6766
7
17230
7
14928
7
15920
7
4945
7
12729
7
12784
7
13638
7
8648
7
5699
7
5267
7
12270
7
10882
7
5840
7
15998
7
4478
7
5379
7
16604
7
12033
7
12989
7
4826...

output:

((|)(|(|(|)(|)))|(|))
((|)(|(|)(|)(|))(|)|)
(|(|(|)((|)|))(|(|)))
((|(|))|(|))(|(|))(|)
(|)((|(|)((|)|)(|))|)
(((|(|)(|))|((|)|))|)
((|)((|(|))(|(|))|)|)
(|)(|)(|(|))((|((|)|))|)
((|)|)((|)|)(((|)|)|)
(|)((|)|)(((|)|(|))|)
(|((|)|(|)))(|(|)(|))
((|)|(|(|)((|)|))(|))
(|)(|)(|)((|)|(|))((|)|)
((|)((|)...

result:

ok 1000 lines

Test #7:

score: 100
Accepted
time: 1ms
memory: 3600kb

input:

encode
1000
7
(|(|)(|)(|(((|)|)|)))
7
(((|)|)((|)|)(|(|))|)
7
(|(|))((|)(|)|(|(|)))
7
(|)(|((|((|(|))|))|))
7
(|((|)|(|))(|((|)|)))
7
(|)((|(|)(|(|)))(|)|)
7
(((|)(|)(|)|)|(|(|)))
7
((|(|))|)((|)|)(|(|))
7
(|)(|(|((|)(|)|(|))))
7
(((|)(|)|)|(|))(|)(|)
7
(|)(|(|(|)((|)|))(|))
7
((|)(|)|(((|)|)|(|)))
...

output:

15867
11849
9021
11308
15765
10500
14210
5358
11396
3058
11092
14522
18179
19877
8671
3131
6988
4399
44880
22915
4210
15118
12608
11923
5730
4641
16812
9097
7818
13028
7541
15566
8197
13305
11797
14448
17015
14534
11355
6074
11339
14545
6377
15245
13979
16614
16803
14423
10722
7278
14721
11399
9036
...

input:

decode
1000
7
15867
7
11849
7
9021
7
11308
7
15765
7
10500
7
14210
7
5358
7
11396
7
3058
7
11092
7
14522
8
18179
8
19877
7
8671
7
3131
7
6988
7
4399
8
44880
8
22915
7
4210
7
15118
7
12608
7
11923
7
5730
7
4641
7
16812
7
9097
7
7818
7
13028
7
7541
7
15566
7
8197
7
13305
7
11797
7
14448
7
17015
7
1453...

output:

(|(|)(|)(|(((|)|)|)))
(((|)|)((|)|)(|(|))|)
(|(|))((|)(|)|(|(|)))
(|)(|((|((|(|))|))|))
(|((|)|(|))(|((|)|)))
(|)((|(|)(|(|)))(|)|)
(((|)(|)(|)|)|(|(|)))
((|(|))|)((|)|)(|(|))
(|)(|(|((|)(|)|(|))))
(((|)(|)|)|(|))(|)(|)
(|)(|(|(|)((|)|))(|))
((|)(|)|(((|)|)|(|)))
(|)(|)(|(|(|(|))))(|)(|)
(|)(|)(|)(|...

result:

ok 1000 lines

Test #8:

score: 100
Accepted
time: 1ms
memory: 3828kb

input:

encode
1000
7
(((|)|(|)(|)(|)(|))|)
7
(|)(|(|(|)))((|(|))|)
7
((|)|)(|((|)|))(|(|))
7
(|(|(|)))((|(|(|)))|)
7
(((|)(|)|)|(|(|)))(|)
7
((|)((((|)|)|)|)|(|))
7
(|((|((|)|(|))(|))|))
7
((|)(((|)(|)(|)|)|)|)
8
(|)(|)(|)(|(|))((|)|(|))
7
(|(|(|))(|)((|(|))|))
7
((((|(|))|)(|)(|)|)|)
7
(|(|))((|)(|)|)((|)...

output:

13274
6673
5472
7945
4574
13909
16711
12614
39778
15671
12756
5495
7205
13250
7626
10585
16002
14410
14192
4349
16656
7202
6182
4991
4088
12966
11222
7678
10703
15461
16352
14776
3091
3030
8558
20024
14717
14314
4415
4153
15240
14878
13964
15109
11924
2966
8565
4920
17184
5999
13601
5261
15725
15287...

input:

decode
1000
7
13274
7
6673
7
5472
7
7945
7
4574
7
13909
7
16711
7
12614
8
39778
7
15671
7
12756
7
5495
7
7205
7
13250
7
7626
7
10585
7
16002
7
14410
7
14192
7
4349
7
16656
7
7202
7
6182
7
4991
7
4088
7
12966
7
11222
7
7678
7
10703
7
15461
7
16352
7
14776
7
3091
7
3030
7
8558
8
20024
7
14717
7
14314
...

output:

(((|)|(|)(|)(|)(|))|)
(|)(|(|(|)))((|(|))|)
((|)|)(|((|)|))(|(|))
(|(|(|)))((|(|(|)))|)
(((|)(|)|)|(|(|)))(|)
((|)((((|)|)|)|)|(|))
(|((|((|)|(|))(|))|))
((|)(((|)(|)(|)|)|)|)
(|)(|)(|)(|(|))((|)|(|))
(|(|(|))(|)((|(|))|))
((((|(|))|)(|)(|)|)|)
(|(|))((|)(|)|)((|)|)
((|)|)(|)(((|)|(|))|)
((((|)|)|(|...

result:

ok 1000 lines

Test #9:

score: 100
Accepted
time: 1ms
memory: 3820kb

input:

encode
1000
7
((|(|)(|(|)))|)((|)|)
7
(|(|))((|(|(|(|))))|)
7
(|)(|(|((|)(|)|)))(|)
8
(|)(|)(|(|)(|))(|(|(|)))
7
(|((((|(|))|)|(|))|))
7
(((|(|))|)|)(|)((|)|)
7
((|(|))((|)|)|((|)|))
7
(((|(|))(|)|)(|)(|)|)
7
(|(|))(|(|)(|)(|)(|))
7
(((|)((|)|)|(|))(|)|)
7
((|(|)((|(|))|))(|)|)
7
(|)((|(|))(|)|((|)|...

output:

5894
9005
4099
40392
16675
5210
14164
11452
9041
11698
11759
10896
4147
9028
14470
5721
10824
14199
13480
22919
6158
3978
4752
33720
14141
15987
10911
5198
10456
5645
22910
15371
13005
7820
48659
3288
10653
15094
3951
6820
14208
48612
5099
14482
16223
13409
14433
14048
4984
14188
15386
17211
7558
50...

input:

decode
1000
7
5894
7
9005
7
4099
8
40392
7
16675
7
5210
7
14164
7
11452
7
9041
7
11698
7
11759
7
10896
7
4147
7
9028
7
14470
7
5721
7
10824
7
14199
7
13480
8
22919
7
6158
7
3978
7
4752
8
33720
7
14141
7
15987
7
10911
7
5198
7
10456
7
5645
8
22910
7
15371
7
13005
7
7820
8
48659
7
3288
7
10653
7
15094...

output:

((|(|)(|(|)))|)((|)|)
(|(|))((|(|(|(|))))|)
(|)(|(|((|)(|)|)))(|)
(|)(|)(|(|)(|))(|(|(|)))
(|((((|(|))|)|(|))|))
(((|(|))|)|)(|)((|)|)
((|(|))((|)|)|((|)|))
(((|(|))(|)|)(|)(|)|)
(|(|))(|(|)(|)(|)(|))
(((|)((|)|)|(|))(|)|)
((|(|)((|(|))|))(|)|)
(|)((|(|))(|)|((|)|))
((((|)(|)|)|)(|)|)(|)
(|(|))((|)|...

result:

ok 1000 lines

Test #10:

score: 100
Accepted
time: 1ms
memory: 3536kb

input:

encode
1000
7
((((|)|(|)(|))|)(|)|)
7
(((|)(|)|)(|)(|(|))|)
7
(|)(|((|(|)(|))(|)|))
7
(|(|)(((|)|)|(|))(|))
7
(|)((|(|))|(|(|(|))))
7
((|(|)(|)(|)(|))|)(|)
7
(|((|)(|(|)((|)|))|))
7
(((|)|(|))|)((|)|)(|)
7
(|)(((|(|))|(|))|(|))
7
(|(|))(|((|)|))(|(|))
7
(|(|)(|))(|(|((|)|)))
7
((|(|)(|))|(|))(|)(|)
...

output:

11678
11816
11256
15249
10966
4420
16591
3287
10872
5511
7829
3062
10871
8689
2913
5063
11706
7024
17205
3082
21736
5469
12074
15740
48643
5277
8635
5924
14436
4452
9072
11667
4751
12680
4195
16631
6002
11406
4524
15575
4034
11267
15854
4395
12594
13350
16799
14575
21019
14050
5651
15241
3379
10964
...

input:

decode
1000
7
11678
7
11816
7
11256
7
15249
7
10966
7
4420
7
16591
7
3287
7
10872
7
5511
7
7829
7
3062
7
10871
7
8689
7
2913
7
5063
7
11706
7
7024
7
17205
7
3082
8
21736
7
5469
7
12074
7
15740
8
48643
7
5277
7
8635
7
5924
7
14436
7
4452
7
9072
7
11667
7
4751
7
12680
7
4195
7
16631
7
6002
7
11406
7
4...

output:

((((|)|(|)(|))|)(|)|)
(((|)(|)|)(|)(|(|))|)
(|)(|((|(|)(|))(|)|))
(|(|)(((|)|)|(|))(|))
(|)((|(|))|(|(|(|))))
((|(|)(|)(|)(|))|)(|)
(|((|)(|(|)((|)|))|))
(((|)|(|))|)((|)|)(|)
(|)(((|(|))|(|))|(|))
(|(|))(|((|)|))(|(|))
(|(|)(|))(|(|((|)|)))
((|(|)(|))|(|))(|)(|)
(|)((((|)|)|(|))|(|))
((|)|)(|(|)(((...

result:

ok 1000 lines

Test #11:

score: 100
Accepted
time: 1ms
memory: 3628kb

input:

encode
1000
7
(|((|)(|)|(|))(|(|)))
7
(|(((|)|)(|((|)|))|))
7
(|)((|)((|)|)|)(|)(|)
7
(|(|))(|)(((|)(|)|)|)
7
(|(|(|((|)|(|)))))(|)
7
((|)(|(|))|(|))((|)|)
7
(|)((|)(|)|)(|(|))(|)
7
(|(((|)|(|(|)))|(|)))
7
(((|)((|)|)(|)|)|)(|)
7
((|)|)((((|)(|)|)|)|)
7
(((|)|(|)(|))|)((|)|)
7
(|(((|)(|)|)|(|(|))))
...

output:

15582
16518
2957
7269
5076
5933
3240
16822
4322
8599
5870
16856
4164
5729
48607
4467
17271
3014
12862
12934
12747
11483
4335
16696
4291
8224
48536
13574
12659
13116
14458
4573
12336
15308
6750
8597
4069
7608
15199
15779
5011
6985
15253
15366
10949
15342
15023
10657
15656
10764
6740
3135
10855
4559
4...

input:

decode
1000
7
15582
7
16518
7
2957
7
7269
7
5076
7
5933
7
3240
7
16822
7
4322
7
8599
7
5870
7
16856
7
4164
7
5729
8
48607
7
4467
7
17271
7
3014
7
12862
7
12934
7
12747
7
11483
7
4335
7
16696
7
4291
7
8224
8
48536
7
13574
7
12659
7
13116
7
14458
7
4573
7
12336
7
15308
7
6750
7
8597
7
4069
7
7608
7
15...

output:

(|((|)(|)|(|))(|(|)))
(|(((|)|)(|((|)|))|))
(|)((|)((|)|)|)(|)(|)
(|(|))(|)(((|)(|)|)|)
(|(|(|((|)|(|)))))(|)
((|)(|(|))|(|))((|)|)
(|)((|)(|)|)(|(|))(|)
(|(((|)|(|(|)))|(|)))
(((|)((|)|)(|)|)|)(|)
((|)|)((((|)(|)|)|)|)
(((|)|(|)(|))|)((|)|)
(|(((|)(|)|)|(|(|))))
((|(|)((|)|))(|)|)(|)
((|)((|)|)(|)|...

result:

ok 1000 lines

Test #12:

score: 100
Accepted
time: 1ms
memory: 3776kb

input:

encode
1000
7
(|(|(|(|)(|)(|(|)))))
7
(|(|(|(|(|)))(|)))(|)
7
(|(((|)(|(|))|)|)(|))
7
(|((|)(|(|(|))(|))|))
7
(|)((|)(|)|(((|)|)|))
7
((|(|))(|)(|)(|)(|)|)
7
(((|(|))|)|)((|(|))|)
7
((|(|(|))((|)(|)|))|)
7
(|(|)(|(|(|))(|))(|))
7
(|((|)|(|)(|(|)))(|))
7
(|((|)|(|)(|)(|(|))))
7
((|)|((|)(|(|(|)))|))
...

output:

17310
5025
15307
16589
10935
11417
6790
13479
15256
15361
16929
14920
10687
12679
21734
12349
4360
16284
13734
15032
9048
7420
10660
15104
13802
12656
13808
3285
14722
4643
17340
2977
14077
12690
6168
11172
16354
12978
14402
17353
5087
8690
14109
4207
5047
7212
6792
4698
7942
2986
4417
14872
11642
4...

input:

decode
1000
7
17310
7
5025
7
15307
7
16589
7
10935
7
11417
7
6790
7
13479
7
15256
7
15361
7
16929
7
14920
7
10687
7
12679
8
21734
7
12349
7
4360
7
16284
7
13734
7
15032
7
9048
7
7420
7
10660
7
15104
7
13802
7
12656
7
13808
7
3285
7
14722
7
4643
7
17340
7
2977
7
14077
7
12690
7
6168
7
11172
7
16354
7...

output:

(|(|(|(|)(|)(|(|)))))
(|(|(|(|(|)))(|)))(|)
(|(((|)(|(|))|)|)(|))
(|((|)(|(|(|))(|))|))
(|)((|)(|)|(((|)|)|))
((|(|))(|)(|)(|)(|)|)
(((|(|))|)|)((|(|))|)
((|(|(|))((|)(|)|))|)
(|(|)(|(|(|))(|))(|))
(|((|)|(|)(|(|)))(|))
(|((|)|(|)(|)(|(|))))
((|)|((|)(|(|(|)))|))
(|)(((|)(|(|(|)))|)|)
((|)((|)|(|((|...

result:

ok 1000 lines

Test #13:

score: 100
Accepted
time: 1ms
memory: 3628kb

input:

encode
1000
7
(|(|((|)|))(|))((|)|)
7
((|)(|)|)(|)(|(|(|)))
7
((((|(|))|(|(|)))|)|)
8
(|)(|)(|)(|(((|)|)|)(|))
7
((((((|)|)|)|)|)|(|))
7
(((|((|)|)((|)|))|)|)
7
(|(|((|)|))(|)((|)|))
7
((|)(|)|(|((|(|))|)))
7
(|(|(|(|)(|)(|)))(|))
7
(|(|)((|)|(((|)|)|)))
7
((((|((|)(|)|))|)|)|)
7
(|(|))(|(|)(|))(|(|...

output:

6056
6313
13048
48635
13976
13079
15470
14535
15423
16315
13020
5508
13916
4555
17173
4155
16955
12695
12974
7041
6611
10725
10670
14389
3971
3481
14165
11052
6045
14300
6712
5220
10881
6122
16964
3714
5982
16860
55276
10937
5009
15066
9070
11601
11363
13388
10962
11670
15357
16368
48667
48565
3413
...

input:

decode
1000
7
6056
7
6313
7
13048
8
48635
7
13976
7
13079
7
15470
7
14535
7
15423
7
16315
7
13020
7
5508
7
13916
7
4555
7
17173
7
4155
7
16955
7
12695
7
12974
7
7041
7
6611
7
10725
7
10670
7
14389
7
3971
7
3481
7
14165
7
11052
7
6045
7
14300
7
6712
7
5220
7
10881
7
6122
7
16964
7
3714
7
5982
7
16860...

output:

(|(|((|)|))(|))((|)|)
((|)(|)|)(|)(|(|(|)))
((((|(|))|(|(|)))|)|)
(|)(|)(|)(|(((|)|)|)(|))
((((((|)|)|)|)|)|(|))
(((|((|)|)((|)|))|)|)
(|(|((|)|))(|)((|)|))
((|)(|)|(|((|(|))|)))
(|(|(|(|)(|)(|)))(|))
(|(|)((|)|(((|)|)|)))
((((|((|)(|)|))|)|)|)
(|(|))(|(|)(|))(|(|))
((|)(((|)|)|(|))|(|))
((|)(|)(|)|...

result:

ok 1000 lines

Test #14:

score: 100
Accepted
time: 1ms
memory: 3616kb

input:

encode
1000
8
(|(|((|)|)))(|(|)((|)|))
8
(|)(|(|)((|)(|)(|)|)(|))
8
(|)((|(|(|)(|))(|(|)))|)
8
(|)((|(((|)|)|))(|)|)(|)
8
(|((|)(|(|)(|(|)(|)))|))
8
(((|)|(|))(|((|)|(|)))|)
8
((|)(((|(|))(|)|)(|)|)|)
8
((|)((|)|)((|)(|)|)(|)|)
8
((|)|)(|(|(|)((|)|)(|)))
8
(|(|))(|((|)|(|((|)|))))
8
((((|)(|)(|)|(|)...

output:

48238
72650
70855
25091
107948
79764
82482
75417
57818
60119
85200
95218
101006
26003
108961
40572
50574
95229
33695
36522
92974
72185
98489
28805
105928
25913
18612
90632
27633
74471
110608
93013
98064
86235
88287
102273
107197
27951
17720
47218
70164
60082
107931
29443
25570
33999
72217
46218
9952...

input:

decode
1000
8
48238
8
72650
8
70855
8
25091
8
107948
8
79764
8
82482
8
75417
8
57818
8
60119
8
85200
8
95218
8
101006
8
26003
8
108961
8
40572
8
50574
8
95229
8
33695
8
36522
8
92974
8
72185
8
98489
8
28805
8
105928
8
25913
8
18612
8
90632
8
27633
8
74471
8
110608
8
93013
8
98064
8
86235
8
88287
8
1...

output:

(|(|((|)|)))(|(|)((|)|))
(|)(|(|)((|)(|)(|)|)(|))
(|)((|(|(|)(|))(|(|)))|)
(|)((|(((|)|)|))(|)|)(|)
(|((|)(|(|)(|(|)(|)))|))
(((|)|(|))(|((|)|(|)))|)
((|)(((|(|))(|)|)(|)|)|)
((|)((|)|)((|)(|)|)(|)|)
((|)|)(|(|(|)((|)|)(|)))
(|(|))(|((|)|(|((|)|))))
((((|)(|)(|)|(|)(|))|)|)
(((|)|)|((|)(|)(|)|(|)))
...

result:

ok 1000 lines

Test #15:

score: 100
Accepted
time: 1ms
memory: 3612kb

input:

encode
1000
9
((|)((|((|)(|)|(|(|))))|)|)
9
((((|)(|(|))|(((|)|)|))|)|)
9
(|((|((|)(((|)|)|)|))|(|)))
9
(((((|)|)|)((|)(|)|)(|)|)|)
9
(|)(((|(|))(|(|))|)(|)|(|))
9
(|)(|((|)|)(|)(|)(|)((|)|))
9
((((|)(|(|))|)(|)|)(|(|))|)
9
(|(|))(((|)(|)|(|(|))(|))|)
9
(|(((|)|(|))|(|)((|)|))(|))
9
(((|(|)((|)(|)|)...

output:

555325
570655
728458
559731
478639
489359
520347
402277
665939
512233
728225
361912
564213
630900
664454
709200
281207
115835
121230
539743
713033
271409
473711
254835
113842
485307
636918
114144
465540
649135
510812
674607
724014
638710
116964
722972
165875
681281
401835
489104
250544
743897
275760...

input:

decode
1000
9
555325
9
570655
9
728458
9
559731
9
478639
9
489359
9
520347
9
402277
9
665939
9
512233
9
728225
9
361912
9
564213
9
630900
9
664454
9
709200
9
281207
9
115835
9
121230
9
539743
9
713033
9
271409
9
473711
9
254835
9
113842
9
485307
9
636918
9
114144
9
465540
9
649135
9
510812
9
674607
...

output:

((|)((|((|)(|)|(|(|))))|)|)
((((|)(|(|))|(((|)|)|))|)|)
(|((|((|)(((|)|)|)|))|(|)))
(((((|)|)|)((|)(|)|)(|)|)|)
(|)(((|(|))(|(|))|)(|)|(|))
(|)(|((|)|)(|)(|)(|)((|)|))
((((|)(|(|))|)(|)|)(|(|))|)
(|(|))(((|)(|)|(|(|))(|))|)
(|(((|)|(|))|(|)((|)|))(|))
(((|(|)((|)(|)|)(|))|)(|)|)
(|((|((|(|))|)(|)(|)...

result:

ok 1000 lines

Test #16:

score: 100
Accepted
time: 2ms
memory: 3784kb

input:

encode
1000
10
(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
10
((((((((((|)|)|)|)|)|)|)|)|)|)
10
(|(|(|(|(|(|(|(|(|(|))))))))))
10
((|)|)((|)|(((|)|)|)(|((|)|)))
10
(|)((|)|((|((|)(|((|)|))|))|))
10
(|)(((|)|)((|(|))((|)|)(|)|)|)
10
((|)(|((|)|))(|)((|(|))|(|))|)
10
(((((((|(|(|)))|)|)|)(|)|)|)|)
10
(((|)|((|)|))...

output:

749522
3885079
5091284
2680023
3329384
3220075
3599649
3876442
1675590
2758103
4442970
1602667
2015690
3239186
2011687
2488035
2486701
4483136
4389183
4255206
4831891
4298109
3506763
4023991
2584413
1587443
1258450
4442832
3926886
3839593
1446367
3341548
1207716
4644971
3294676
3899343
985426
500493...

input:

decode
1000
10
749522
10
3885079
10
5091284
10
2680023
10
3329384
10
3220075
10
3599649
10
3876442
10
1675590
10
2758103
10
4442970
10
1602667
10
2015690
10
3239186
10
2011687
10
2488035
10
2486701
10
4483136
10
4389183
10
4255206
10
4831891
10
4298109
10
3506763
10
4023991
10
2584413
10
1587443
10
...

output:

(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
((((((((((|)|)|)|)|)|)|)|)|)|)
(|(|(|(|(|(|(|(|(|(|))))))))))
((|)|)((|)|(((|)|)|)(|((|)|)))
(|)((|)|((|((|)(|((|)|))|))|))
(|)(((|)|)((|(|))((|)|)(|)|)|)
((|)(|((|)|))(|)((|(|))|(|))|)
(((((((|(|(|)))|)|)|)(|)|)|)|)
(((|)|((|)|))|)(|)(|)((|)(|)|)
(|(|))(((|)|)(|)(|(|(...

result:

ok 1000 lines

Test #17:

score: 100
Accepted
time: 2ms
memory: 3624kb

input:

encode
1000
11
(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
11
(((((((((((|)|)|)|)|)|)|)|)|)|)|)
11
(|(|(|(|(|(|(|(|(|(|(|)))))))))))
11
((|)|)((|(|))(|)(|)(|)|((|)(|)|))
11
(|((((|)|)|)|((|(|(((|)|)|)))|)))
11
((|)|(((|)|(|((|((|)|))|)(|)))|))
11
(((|)|)|)((|(|)(((|)|)|))(|(|))|)
11
((|)((|)|)|((|)((|)|)|(|(|...

output:

5091285
26920888
35147729
18675535
34359669
30638393
17022136
29763631
29664183
30683675
14305225
8794509
28798551
13098761
29668110
8858046
5659480
22214216
29472126
22545698
31809453
27157929
5740182
6266801
12424002
13258697
27208312
26865521
23684345
11043773
29217721
11456956
32059956
34989495
...

input:

decode
1000
11
5091285
11
26920888
11
35147729
11
18675535
11
34359669
11
30638393
11
17022136
11
29763631
11
29664183
11
30683675
11
14305225
11
8794509
11
28798551
11
13098761
11
29668110
11
8858046
11
5659480
11
22214216
11
29472126
11
22545698
11
31809453
11
27157929
11
5740182
11
6266801
11
124...

output:

(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
(((((((((((|)|)|)|)|)|)|)|)|)|)|)
(|(|(|(|(|(|(|(|(|(|(|)))))))))))
((|)|)((|(|))(|)(|)(|)|((|)(|)|))
(|((((|)|)|)|((|(|(((|)|)|)))|)))
((|)|(((|)|(|((|((|)|))|)(|)))|))
(((|)|)|)((|(|)(((|)|)|))(|(|))|)
((|)((|)|)|((|)((|)|)|(|(|(|)))))
((|(|)(|)(|))|((|(|))(|)|)(|...

result:

ok 1000 lines

Test #18:

score: 100
Accepted
time: 2ms
memory: 3780kb

input:

encode
1000
12
(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
12
((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)
12
(|(|(|(|(|(|(|(|(|(|(|(|))))))))))))
12
((|)|)((|)(|(|))(|(|))(|)((|)(|)|)|)
12
(((|(|((|)|))(|))(|)|)|)(((|)|)|(|))
12
((|)|)(|(|)((|(|((|)(|)|)))(|(|))|))
12
((|(|((|)|(|))(|)((|)|)(|)(|)(|)))|)
12
(|((|...

output:

35147730
188901408
245878740
131150807
90957132
132391323
196491734
216314785
212352117
40022387
191369010
233893914
122699768
162466841
208969467
162006494
110833001
240376112
59469372
62251486
203372684
54867222
245823418
117459004
59852374
58545678
113689289
196404005
189957396
48688373
135862575...

input:

decode
1000
12
35147730
12
188901408
12
245878740
12
131150807
12
90957132
12
132391323
12
196491734
12
216314785
12
212352117
12
40022387
12
191369010
12
233893914
12
122699768
12
162466841
12
208969467
12
162006494
12
110833001
12
240376112
12
59469372
12
62251486
12
203372684
12
54867222
12
24582...

output:

(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)
(|(|(|(|(|(|(|(|(|(|(|(|))))))))))))
((|)|)((|)(|(|))(|(|))(|)((|)(|)|)|)
(((|(|((|)|))(|))(|)|)|)(((|)|)|(|))
((|)|)(|(|)((|(|((|)(|)|)))(|(|))|))
((|(|((|)|(|))(|)((|)|)(|)(|)(|)))|)
(|((|)((|)|(|(|))((|)|))|(|))(|)(|))
((|)...

result:

ok 1000 lines

Test #19:

score: 100
Accepted
time: 2ms
memory: 3776kb

input:

encode
1000
13
(((|)|(|((|)|)(|))(|)((|)|))(|((|)|))|)
13
(|((|)((|)|)((((|)|)((|)|)|)(|)|(|))|))
13
(|(|(|(|))(|)(|)(|(|((|)|)))(|(|))))(|)
13
((|(((|)|)(|(|))|((|)|(|))))((|(|))|)|)
13
(|)(((((|)|)|)(|)(|)(|(((|)|)|(|)))|)|)
13
((|((|)(|)(|)((|)|)|))|)(|)(|((|)(|)|))
13
(|(|)(|)((|(|(|(|)))(|))(|(...

output:

1235762144
1672031724
452984902
1236903710
1126952933
607985632
1620634921
666997556
1712985960
1493039474
739106389
879651835
828299380
555770310
1216983542
709178562
1129256605
1621057728
557465242
818809746
1613304943
1649113747
421431853
622850306
1203281687
966359987
1310355531
534032731
144643...

input:

decode
1000
13
1235762144
13
1672031724
13
452984902
13
1236903710
13
1126952933
13
607985632
13
1620634921
13
666997556
13
1712985960
13
1493039474
13
739106389
13
879651835
13
828299380
13
555770310
13
1216983542
13
709178562
13
1129256605
13
1621057728
13
557465242
13
818809746
13
1613304943
13
1...

output:

(((|)|(|((|)|)(|))(|)((|)|))(|((|)|))|)
(|((|)((|)|)((((|)|)((|)|)|)(|)|(|))|))
(|(|(|(|))(|)(|)(|(|((|)|)))(|(|))))(|)
((|(((|)|)(|(|))|((|)|(|))))((|(|))|)|)
(|)(((((|)|)|)(|)(|)(|(((|)|)|(|)))|)|)
((|((|)(|)(|)((|)|)|))|)(|)(|((|)(|)|))
(|(|)(|)((|(|(|(|)))(|))(|((|)|))|(|)))
(|)(|((|(|(|)(|)))|)...

result:

ok 1000 lines

Test #20:

score: 100
Accepted
time: 2ms
memory: 3616kb

input:

encode
1000
14
(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
14
((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)
14
(|(|(|(|(|(|(|(|(|(|(|(|(|(|))))))))))))))
14
((|)|(|))(|((|)|))((|)((|)|(|)(|(|)))(|)|)
14
(|((|)|(|)((((|)|)|)(|)(|)|(|(((|)|)|)))))
14
(((|)|(|))|(|(|)(|))(|(|)))(|(((|)|(|))|))
14
(|)(|)(|(...

output:

1739182034
9584699433
12417552340
5289200280
12194602489
4743956279
2064022931
10163551736
3703312454
10522167104
11316597522
10161870201
3084484826
10155410030
11993141117
4787835979
11401994621
1878134429
11118410303
3075412335
3969480362
5634080517
2401901628
4961742404
8368287900
11812186262
435...

input:

decode
1000
14
1739182034
14
9584699433
14
12417552340
14
5289200280
14
12194602489
14
4743956279
14
2064022931
14
10163551736
14
3703312454
14
10522167104
14
11316597522
14
10161870201
14
3084484826
14
10155410030
14
11993141117
14
4787835979
14
11401994621
14
1878134429
14
11118410303
14
307541233...

output:

(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)
(|(|(|(|(|(|(|(|(|(|(|(|(|(|))))))))))))))
((|)|(|))(|((|)|))((|)((|)|(|)(|(|)))(|)|)
(|((|)|(|)((((|)|)|)(|)(|)|(|(((|)|)|)))))
(((|)|(|))|(|(|)(|))(|(|)))(|(((|)|(|))|))
(|)(|)(|(|)(|(|))((|)(|)(|)|))(|((|)|))(|)...

result:

ok 1000 lines

Test #21:

score: 100
Accepted
time: 2ms
memory: 3616kb

input:

encode
1000
15
((|(|))|(|(|((|((|)(|)|)(|(|)))|)))((|)|(|)))
15
(|)(|)(|(|(|)(|((|)(|((|)|))|)(|)))((|)(|)|))
15
((|)|)((|)(|)(|(|(|)(|)(|))((|)|))(|)|(|(|)))
15
(|(|)((|)|(((|)|)(|)(|)(|)|(|)))((|)|))((|)|)
15
((|(|(|)((|)|)((|)|((|(|))(|)|))))|)(|(|))(|)
15
(|)((|)|(|(|)))(((|)((|)|)|)|(|(|)(|((|)...

output:

77044137969
47441780210
48783161168
27057028824
14395579934
40564062566
59618355801
32086777538
67739632088
71553026999
40273712661
68686069383
86539674601
85533572078
76936778361
65003646323
79204950616
72671250068
27113065026
69604300057
40268070201
58032605849
75879762525
26637468901
44774309412
...

input:

decode
1000
15
77044137969
15
47441780210
15
48783161168
15
27057028824
15
14395579934
15
40564062566
15
59618355801
15
32086777538
15
67739632088
15
71553026999
15
40273712661
15
68686069383
15
86539674601
15
85533572078
15
76936778361
15
65003646323
15
79204950616
15
72671250068
15
27113065026
15
...

output:

((|(|))|(|(|((|((|)(|)|)(|(|)))|)))((|)|(|)))
(|)(|)(|(|(|)(|((|)(|((|)|))|)(|)))((|)(|)|))
((|)|)((|)(|)(|(|(|)(|)(|))((|)|))(|)|(|(|)))
(|(|)((|)|(((|)|)(|)(|)(|)|(|)))((|)|))((|)|)
((|(|(|)((|)|)((|)|((|(|))(|)|))))|)(|(|))(|)
(|)((|)|(|(|)))(((|)((|)|)|)|(|(|)(|((|)|))))
(|)((|)|((|)((|(|)((|)(|...

result:

ok 1000 lines

Test #22:

score: 100
Accepted
time: 1ms
memory: 3780kb

input:

encode
1000
16
(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
16
((((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)
16
(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|))))))))))))))))
16
((|)|(|(|)))(|)((|)(|(|(|(|))))((|)|(|))(|(|))|)
16
((((|)|)(|)|(|)(|)(|(|)((|)((|)|)|))(|))(|)|(|))
16
(|(|))(|((|)|(|((|)(|(|(|...

output:

89375231954
501709072434
647778914260
292650641280
523204027637
367825291374
628980475062
451804031573
117977258014
328176744100
90798970554
608952031375
521406670302
533112801209
271773623349
491974864161
552722617192
160032130371
432306628689
366330136940
200544091239
626342197016
97593759952
6196...

input:

decode
1000
16
89375231954
16
501709072434
16
647778914260
16
292650641280
16
523204027637
16
367825291374
16
628980475062
16
451804031573
16
117977258014
16
328176744100
16
90798970554
16
608952031375
16
521406670302
16
533112801209
16
271773623349
16
491974864161
16
552722617192
16
160032130371
16...

output:

(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
((((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)
(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|))))))))))))))))
((|)|(|(|)))(|)((|)(|(|(|(|))))((|)|(|))(|(|))|)
((((|)|)(|)|(|)(|)(|(|)((|)((|)|)|))(|))(|)|(|))
(|(|))(|((|)|(|((|)(|(|(|)))|))((|)(|)|(|(|)))))
(|((|(...

result:

ok 1000 lines

Test #23:

score: 100
Accepted
time: 3ms
memory: 3628kb

input:

encode
1000
17
(((((|)(|(((|)|)|))|((|)|))(|(|(|))(|))|(|(|)))|)|)
17
((|((|((|((|)|))|(|)))|))|(|(((|)|)|)((|)|))((|)|))
17
((|)(|)|)(|)((|(|(|)((|(|))|))(|(|)((|)(|)|)))(|)|)
17
((((|)|)((|(|((|(((|)|)(|)|))|)(|(|)(|))(|)))|)|)|)
17
(((|)|)|(|(|((|(|(|(|))(|)(|)))((|)(|)|)|)((|)|))))
17
(|(|(((|)|...

output:

3668158302031
3991732008046
2233109153103
3643298972496
4077563888483
4233664802125
3999316536854
1662607861170
1407675144733
4705958067436
1062756669828
1525162668627
4705289121411
4149352893355
4506655017982
1776174324481
2351966944462
815834582546
4344115972900
1482796122261
1751517779587
3949298...

input:

decode
1000
17
3668158302031
17
3991732008046
17
2233109153103
17
3643298972496
17
4077563888483
17
4233664802125
17
3999316536854
17
1662607861170
17
1407675144733
17
4705958067436
17
1062756669828
17
1525162668627
17
4705289121411
17
4149352893355
17
4506655017982
17
1776174324481
17
2351966944462...

output:

(((((|)(|(((|)|)|))|((|)|))(|(|(|))(|))|(|(|)))|)|)
((|((|((|((|)|))|(|)))|))|(|(((|)|)|)((|)|))((|)|))
((|)(|)|)(|)((|(|(|)((|(|))|))(|(|)((|)(|)|)))(|)|)
((((|)|)((|(|((|(((|)|)(|)|))|)(|(|)(|))(|)))|)|)|)
(((|)|)|(|(|((|(|(|(|))(|)(|)))((|)(|)|)|)((|)|))))
(|(|(((|)|)(|)|(|(|((|)|(|))(|)(|(|)))))...

result:

ok 1000 lines

Test #24:

score: 100
Accepted
time: 3ms
memory: 3608kb

input:

encode
1000
18
(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
18
((((((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)
18
(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|))))))))))))))))))
18
((|)|((|(|))|(|)))(((|)|)((|)|)|)((|)|)(|(|))((|)|)(|)
18
((|)((|)|(|((|)|))((|(|))((|)(((|)|)|((|)|))|(|))|))|...

output:

4723775754194
26893722904635
34633382744020
5316359408115
26398339965555
29921857583149
8580048377806
5724358317628
8298826607118
31747357338944
12682112329123
14887498558509
32524052509927
12465998464315
34444638128549
6124523713028
26705814460411
34053714826400
6134201468156
33017314169734
2254622...

input:

decode
1000
18
4723775754194
18
26893722904635
18
34633382744020
18
5316359408115
18
26398339965555
18
29921857583149
18
8580048377806
18
5724358317628
18
8298826607118
18
31747357338944
18
12682112329123
18
14887498558509
18
32524052509927
18
12465998464315
18
34444638128549
18
6124523713028
18
267...

output:

(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
((((((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)
(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|))))))))))))))))))
((|)|((|(|))|(|)))(((|)|)((|)|)|)((|)|)(|(|))((|)|)(|)
((|)((|)|(|((|)|))((|(|))((|)(((|)|)|((|)|))|(|))|))|)
(((|)|)|(|(|(|(|)(((((|)|...

result:

ok 1000 lines

Test #25:

score: 100
Accepted
time: 3ms
memory: 3756kb

input:

encode
1000
19
(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
19
(((((((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)
19
(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|)))))))))))))))))))
19
((|)|((|(|))|)((|)|(|)))(|)(|(((|)(|)(|)|(|(|))(|))|))(|)
19
(|((((|)(|)|)|)((|(((|)|)(|)|))|)|((|)|)(...

output:

34633382744021
198340684605332
255144014499793
44057916889921
225687490642806
133283158573743
251609885598008
180272648583851
232061761117626
89984011104050
73349115339235
212780587862899
71833600655674
202086990665874
216582951012470
207518346645423
200639537877579
53226898157493
232849396231631
16...

input:

decode
1000
19
34633382744021
19
198340684605332
19
255144014499793
19
44057916889921
19
225687490642806
19
133283158573743
19
251609885598008
19
180272648583851
19
232061761117626
19
89984011104050
19
73349115339235
19
212780587862899
19
71833600655674
19
202086990665874
19
216582951012470
19
20751...

output:

(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
(((((((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)
(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|)))))))))))))))))))
((|)|((|(|))|)((|)|(|)))(|)(|(((|)(|)(|)|(|(|))(|))|))(|)
(|((((|)(|)|)|)((|(((|)|)(|)|))|)|((|)|)((|)|(|)))(|)(|))
(|((|)|))(...

result:

ok 1000 lines

Test #26:

score: 100
Accepted
time: 2ms
memory: 3832kb

input:

encode
1000
20
(|(|(|)))(|((|)|(((|(|(|)))|(|(|))(|(|)))(|)|)(|(|))(|)))(|)
20
((|)|)((((|)|(|))|((|((|)(|)|))(((|)|)(|)(((|(|))|)|)|)|))|)
20
(((((|)|)((((|)|)|)|((((|(|)(|(|)))|)|(|))|))(|)|(|(|)))|)|)
20
(((|((|)|(|))((((|(|)((|(|))(|)((|(|))|)|))|)|)|(|))(|))|)|)
20
((|)((|)(((|(|(|((|)|))))|)|)...

output:

354531638351954
1047412395597500
1470525382538795
1472797341941610
431691117537159
778153955110001
553386386260863
535295223237216
753568774623272
1047227462325470
429394799656654
545075594508688
1869634566797875
560974564725169
860570394905443
990732033535270
801103655202431
1407868395869048
568975...

input:

decode
1000
20
354531638351954
20
1047412395597500
20
1470525382538795
20
1472797341941610
20
431691117537159
20
778153955110001
20
553386386260863
20
535295223237216
20
753568774623272
20
1047227462325470
20
429394799656654
20
545075594508688
20
1869634566797875
20
560974564725169
20
86057039490544...

output:

(|(|(|)))(|((|)|(((|(|(|)))|(|(|))(|(|)))(|)|)(|(|))(|)))(|)
((|)|)((((|)|(|))|((|((|)(|)|))(((|)|)(|)(((|(|))|)|)|)|))|)
(((((|)|)((((|)|)|)|((((|(|)(|(|)))|)|(|))|))(|)|(|(|)))|)|)
(((|((|)|(|))((((|(|)((|(|))(|)((|(|))|)|))|)|)|(|))(|))|)|)
((|)((|)(((|(|(|((|)|))))|)|)|(|((|)(|)|((|)|))))|(|(|))...

result:

ok 1000 lines

Test #27:

score: 100
Accepted
time: 3ms
memory: 3744kb

input:

encode
1000
21
(((|((|(|)(|)(|(|)(|))(|))|))(|(|))|)(|(|))|(((|)|)|(|((|)|))))
21
((|)(|)(|)|(|((|(|)(|((|)|))(|)(|))(|(|)(|)(((|)|(|))(|)|))|)))
21
((|(|(|))(|)((|)|(|)))(|)|(((|)|)|(|(|(|)(|)(((|)(|)|)|)))))(|)
21
(|((|)(|(|))((|)|)(|)(|)((((|)|)|(|)(|))|)|))((|(|((|)|)))(|)|)
21
(|)((|)(|)|(|((((...

output:

11772824807353059
12029174564777138
3232216075775757
5226032531993579
3930362891344980
11758443553140347
9743217520094540
13758121771171030
5277948300184357
3575093218586455
2460247539533595
2871741749926699
2582678781987518
3961195916390211
11528431184937512
12980424104947689
2372899656031041
75862...

input:

decode
1000
21
11772824807353059
21
12029174564777138
21
3232216075775757
21
5226032531993579
21
3930362891344980
21
11758443553140347
21
9743217520094540
21
13758121771171030
21
5277948300184357
21
3575093218586455
21
2460247539533595
21
2871741749926699
21
2582678781987518
21
3961195916390211
21
1...

output:

(((|((|(|)(|)(|(|)(|))(|))|))(|(|))|)(|(|))|(((|)|)|(|((|)|))))
((|)(|)(|)|(|((|(|)(|((|)|))(|)(|))(|(|)(|)(((|)|(|))(|)|))|)))
((|(|(|))(|)((|)|(|)))(|)|(((|)|)|(|(|(|)(|)(((|)(|)|)|)))))(|)
(|((|)(|(|))((|)|)(|)(|)((((|)|)|(|)(|))|)|))((|(|((|)|)))(|)|)
(|)((|)(|)|(|(((((|)|(|))|)|)|((|)|(|))(|)((...

result:

ok 1000 lines

Test #28:

score: 100
Accepted
time: 4ms
memory: 3616kb

input:

encode
1000
22
(|((|)|(|(|(((|)(|)(|)|)((|)(((|)|)|)|)(|)|)))(|(|)))(|(((|)|)|)))
22
((|(|(|)))|(|)(|)((|)|))(((|)|)(|((((|)|)|)|))|(|))((((|)(|)|)|)|)
22
((|(|((|(|))|)))(|(|(|)((|((|((((|)|)|(|))|(|)(|)))|)(|))|)))(|)|)
22
((|)(|((|(|(|(|(|)(|(|)))))(|)(|))(((|)|)|(|))(|((|)|)(|))|))(|)|)
22
(((|)...

output:

95287837505314730
36437537378349654
73070957788596266
73462105619250131
88840816823232108
31185420137042367
23505761198223737
103696761316333426
34526010741686018
38692715958879185
33154087584146224
21607115671022908
74350572843056159
26339415947197090
74643285790070278
31109044082268703
35149210495...

input:

decode
1000
22
95287837505314730
22
36437537378349654
22
73070957788596266
22
73462105619250131
22
88840816823232108
22
31185420137042367
22
23505761198223737
22
103696761316333426
22
34526010741686018
22
38692715958879185
22
33154087584146224
22
21607115671022908
22
74350572843056159
22
26339415947...

output:

(|((|)|(|(|(((|)(|)(|)|)((|)(((|)|)|)|)(|)|)))(|(|)))(|(((|)|)|)))
((|(|(|)))|(|)(|)((|)|))(((|)|)(|((((|)|)|)|))|(|))((((|)(|)|)|)|)
((|(|((|(|))|)))(|(|(|)((|((|((((|)|)|(|))|(|)(|)))|)(|))|)))(|)|)
((|)(|((|(|(|(|(|)(|(|)))))(|)(|))(((|)|)|(|))(|((|)|)(|))|))(|)|)
(((|)(((|(|))|)|)|((|)|))|(((|)(...

result:

ok 1000 lines

Test #29:

score: 100
Accepted
time: 4ms
memory: 3836kb

input:

encode
1000
23
((|)((|)|)(|((|(|(|(|(|))((|)((|)((|)|(|))(|((|(|))(|)|))|)|))))|))|)
23
(|(|)((|)|(|)))(|((|(|(((|((|)|)(|))|)|)))|)((|(|))(|)|(|(|)(|)(|))))
23
(|(|))((((|)|)(|)|(((|(|))|)(|)|))(|((|(|)(|))(|)|(|((|)|)(|))(|)))|)
23
(((|((|)((|(|))(|)|(|))|))((|)|(|(|)(|(|)((|)|(|)))))((|)|(|)(|))|...

output:

581659335883118764
378127192572629175
447809607032074510
603235300284024115
641748036800745910
174202208747320584
618174287839460555
558473346521769974
661377704401912854
267414359241180806
405231736989890357
668485046499485203
586450176279614284
762116747141165017
696281397089116582
749211035681146...

input:

decode
1000
23
581659335883118764
23
378127192572629175
23
447809607032074510
23
603235300284024115
23
641748036800745910
23
174202208747320584
23
618174287839460555
23
558473346521769974
23
661377704401912854
23
267414359241180806
23
405231736989890357
23
668485046499485203
23
586450176279614284
23...

output:

((|)((|)|)(|((|(|(|(|(|))((|)((|)((|)|(|))(|((|(|))(|)|))|)|))))|))|)
(|(|)((|)|(|)))(|((|(|(((|((|)|)(|))|)|)))|)((|(|))(|)|(|(|)(|)(|))))
(|(|))((((|)|)(|)|(((|(|))|)(|)|))(|((|(|)(|))(|)|(|((|)|)(|))(|)))|)
(((|((|)((|(|))(|)|(|))|))((|)|(|(|)(|(|)((|)|(|)))))((|)|(|)(|))|)|)
((((|)|((|)(|(|))|)(...

result:

ok 1000 lines

Test #30:

score: 0
Wrong Answer on the first run

input:

encode
1000
24
(|((((|)|)|)|)(|)(((|)|((|)(|(|))|))|(|))((|(|)(|))|(|(((|)|)|))((|)|)))
24
(|)(|(|)(|((|(|))|))(|)(|((|)((|)|)((|)|)|(((|)|)|)))(|((|)|(|(|))(|))))
24
(|(|((((|)|)(|)(|)((|(|))(|)|)|(|))|((((|(|(|))(|))|)|)|))(|(|)))(|)(|))
24
(|((|(|))|(((|)(|)|)|((|(|(|)((|(|))(|)(|)|(|))))|)((|)((...

output:

5391329950197754489
4002099927055850580
5193960821563752961
5756024696948170565
2573494696743835694
4785411749483411919
1440095165203708732
1395681249226108482
4134864376331277820
1917923329498520198
1505883895409885541
4938366029015439139
1684567947049907317
3290132152874262935
4768737221682144651
...

input:


output:


result:

wrong answer Integer parameter [name=x_i] equals to 5391329950197754489, violates the range [0, 2*10^18] (test case 1)