QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#294836#4824. Bracket-and-bar Sequencesucup-team1631#AC ✓418ms9284kbPython32.2kb2023-12-30 16:54:122023-12-30 16:54:13

Judging History

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

  • [2023-12-30 16:54:13]
  • 评测
  • 测评结果:AC
  • 用时:418ms
  • 内存:9284kb
  • [2023-12-30 16:54:12]
  • 提交

answer

C=[1, 1, 3, 12, 55, 273, 1428, 7752, 43263, 246675, 1430715, 8414640, 50067108, 300830572, 1822766520, 11124755664, 68328754959, 422030545335, 2619631042665, 16332922290300, 102240109897695, 642312451217745, 4048514844039120, 25594403741131680, 162250238001816900, 1031147983159782228]


def decode(n,k):
  if n==0:
    return []
  tmp=0
  for i in range(1,3*n,3):
    for j in range(i+1,3*n,3):
      n1=(i-1)//3
      n2=(j-i-1)//3
      n3=(3*n-j-1)//3
      c1=C[n1]
      c2=C[n2]
      c3=C[n3]
      if tmp+c1*c2*c3<=k:
        tmp+=c1*c2*c3
      else:
        rem=(k-tmp)
        k1=rem//(c2*c3)
        rem-=k1*c2*c3
        k2=rem//c3
        rem-=k2*c3
        k3=rem
        ans=[0]+decode(n1,k1)+[1]+decode(n2,k2)+[2]+decode(n3,k3)
        return ans

def encode(n,a):
  if n==0:
    return 0
  res=[]
  i0=-1
  j0=-1
  for i in range(3*n):
    res.append([a[i],i])
    while len(res)>=3 and res[-3][0]==0 and res[-2][0]==1 and res[-1][0]==2:
      if len(res)==3 and res[-3][1]==0:
        i0=res[-2][1]
        j0=res[-1][1]
      for _ in range(3):
        res.pop()

  if i0==-1:
    assert 0
  k=0
  for i in range(1,3*n,3):
    for j in range(i+1,3*n,3):
      if (i,j)>=(i0,j0):
        continue
      n1=(i-1)//3
      n2=(j-i-1)//3
      n3=(3*n-j-1)//3
      k+=C[n1]*C[n2]*C[n3]
  
  a1=[]
  a2=[]
  a3=[]
  
  for i in range(1,i0):
    a1.append(a[i])
  for i in range(i0+1,j0):
    a2.append(a[i])
  for i in range(j0+1,3*n):
    a3.append(a[i])
  
  n1=(i0-1)//3
  n2=(j0-i0-1)//3
  n3=(3*n-j0-1)//3
  
  k+=encode(n1,a1)*C[n2]*C[n3]+encode(n2,a2)*C[n3]+encode(n3,a3)
  return k


if 0:
  n=8
  for k in range(C[n]):
    A=decode(n,k)
    k2=encode(n,A)
    assert k==k2
  exit()
S=input()
T=int(input())
if S=='encode':
  for _ in range(T):
    n=int(input())
    s=input()
    a=[]
    for i in range(3*n):
      if s[i]=='(':
        a.append(0)
      elif s[i]=='|':
        a.append(1)
      else:
        a.append(2)
    k=encode(n,a)
    print(k+1)
else:
  for _ in range(T):
    n=int(input())
    k=int(input())
    k-=1
    a=decode(n,k)
    s=''
    for i in range(3*n):
      s+='(|)'[a[i]]
    print(s)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 15ms
memory: 9024kb

input:

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

output:

1
55
66

input:

decode
3
1
1
4
55
5
66

output:

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

result:

ok 3 lines

Test #2:

score: 100
Accepted
time: 9ms
memory: 9120kb

input:

encode
1
1
(|)

output:

1

input:

decode
1
1
1

output:

(|)

result:

ok single line: '(|)'

Test #3:

score: 100
Accepted
time: 15ms
memory: 9072kb

input:

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

output:

3
1
2

input:

decode
3
2
3
1
1
2
2

output:

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

result:

ok 3 lines

Test #4:

score: 100
Accepted
time: 43ms
memory: 9020kb

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:

1
2
3
4
5
6
7
8
9
10
11
12
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
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
...

input:

decode
1000
3
1
3
2
3
3
3
4
3
5
3
6
3
7
3
8
3
9
3
10
3
11
3
12
4
1
4
2
4
3
4
4
4
5
4
6
4
7
4
8
4
9
4
10
4
11
4
12
4
13
4
14
4
15
4
16
4
17
4
18
4
19
4
20
4
21
4
22
4
23
4
24
4
25
4
26
4
27
4
28
4
29
4
30
4
31
4
32
4
33
4
34
4
35
4
36
4
37
4
38
4
39
4
40
4
41
4
42
4
43
4
44
4
45
4
46
4
47
4
48
4
49
4...

output:

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

result:

ok 1000 lines

Test #5:

score: 100
Accepted
time: 43ms
memory: 9100kb

input:

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

output:

661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
...

input:

decode
1000
6
661
6
662
6
663
6
664
6
665
6
666
6
667
6
668
6
669
6
670
6
671
6
672
6
673
6
674
6
675
6
676
6
677
6
678
6
679
6
680
6
681
6
682
6
683
6
684
6
685
6
686
6
687
6
688
6
689
6
690
6
691
6
692
6
693
6
694
6
695
6
696
6
697
6
698
6
699
6
700
6
701
6
702
6
703
6
704
6
705
6
706
6
707
6
708
...

output:

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

result:

ok 1000 lines

Test #6:

score: 100
Accepted
time: 60ms
memory: 9036kb

input:

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

output:

6074
6401
2820
4785
1251
7348
6556
323
4031
780
1967
4410
158
5065
2790
3305
2249
5146
3168
4604
3225
2399
6453
7681
6972
4045
400
1989
7099
1128
5552
2742
5887
1715
3829
6602
7709
2329
7192
648
1973
834
4242
3050
2639
2631
6023
3387
1677
3644
6314
4112
4483
1631
402
7657
5267
4381
3528
5360
7430
61...

input:

decode
1000
7
6074
7
6401
7
2820
7
4785
7
1251
7
7348
7
6556
8
323
7
4031
7
780
7
1967
7
4410
8
158
7
5065
7
2790
7
3305
7
2249
7
5146
7
3168
7
4604
7
3225
7
2399
7
6453
7
7681
7
6972
7
4045
7
400
7
1989
7
7099
7
1128
7
5552
7
2742
7
5887
7
1715
7
3829
7
6602
7
7709
7
2329
7
7192
7
648
7
1973
7
834
...

output:

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

result:

ok 1000 lines

Test #7:

score: 100
Accepted
time: 56ms
memory: 9116kb

input:

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

output:

2478
7084
1615
702
3238
1233
5744
4691
584
5205
534
4911
380
63
3982
2164
1897
5966
315
449
5851
2837
6554
7321
5416
4310
3602
1538
1720
7693
4652
3442
233
7149
6327
5329
2920
4898
583
2109
619
4982
1818
2647
6317
3824
3554
5349
1365
1470
4531
578
1600
241
2616
5773
7176
5036
682
2713
4558
6454
289
...

input:

decode
1000
7
2478
7
7084
7
1615
7
702
7
3238
7
1233
7
5744
7
4691
7
584
7
5205
7
534
7
4911
8
380
8
63
7
3982
7
2164
7
1897
7
5966
8
315
8
449
7
5851
7
2837
7
6554
7
7321
7
5416
7
4310
7
3602
7
1538
7
1720
7
7693
7
4652
7
3442
7
233
7
7149
7
6327
7
5329
7
2920
7
4898
7
583
7
2109
7
619
7
4982
7
181...

output:

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

result:

ok 1000 lines

Test #8:

score: 100
Accepted
time: 48ms
memory: 9084kb

input:

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

output:

7141
351
3951
1805
5242
6106
3725
6586
64
2732
7656
1604
3928
7277
4741
1216
2750
5373
5648
6005
3843
3929
2118
2361
443
7735
509
4700
1415
3334
2545
4406
2032
5535
4095
348
4536
5254
5950
5978
2644
4351
6280
2813
7320
908
4134
2427
2924
4246
7038
1977
3324
3508
2220
7684
3263
5405
5600
4202
909
480...

input:

decode
1000
7
7141
7
351
7
3951
7
1805
7
5242
7
6106
7
3725
7
6586
8
64
7
2732
7
7656
7
1604
7
3928
7
7277
7
4741
7
1216
7
2750
7
5373
7
5648
7
6005
7
3843
7
3929
7
2118
7
2361
7
443
7
7735
7
509
7
4700
7
1415
7
3334
7
2545
7
4406
7
2032
7
5535
7
4095
8
348
7
4536
7
5254
7
5950
7
5978
7
2644
7
4351
...

output:

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

result:

ok 1000 lines

Test #9:

score: 100
Accepted
time: 57ms
memory: 9020kb

input:

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

output:

5453
1670
428
334
3820
5156
5658
7295
1517
7324
6735
1021
5982
1590
5314
5485
1113
5626
6846
435
2154
1098
2335
181
5663
2770
1045
5060
1159
994
455
2861
7745
1723
97
5133
1374
3416
1048
5087
5743
189
4607
4902
2674
6782
5351
6156
2391
5643
2881
3153
4633
2275
39
4556
2670
4728
190
1011
2503
1563
28...

input:

decode
1000
7
5453
7
1670
7
428
8
334
7
3820
7
5156
7
5658
7
7295
7
1517
7
7324
7
6735
7
1021
7
5982
7
1590
7
5314
7
5485
7
1113
7
5626
7
6846
8
435
7
2154
7
1098
7
2335
8
181
7
5663
7
2770
7
1045
7
5060
7
1159
7
994
8
455
7
2861
7
7745
7
1723
8
97
7
5133
7
1374
7
3416
7
1048
7
5087
7
5743
8
189
7
4...

output:

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

result:

ok 1000 lines

Test #10:

score: 100
Accepted
time: 51ms
memory: 9036kb

input:

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

output:

7404
7197
689
2633
943
5867
3624
5137
1142
1503
1726
5190
1143
3976
1605
2305
7327
2009
3138
4271
160
3945
6385
3349
90
1940
4087
5189
5301
5871
1525
7414
2336
6491
5960
3830
4270
564
5605
3430
815
687
2489
5989
6544
6935
3559
5022
290
6142
976
2652
3894
942
3694
1908
686
4499
1575
3495
2625
7333
50...

input:

decode
1000
7
7404
7
7197
7
689
7
2633
7
943
7
5867
7
3624
7
5137
7
1142
7
1503
7
1726
7
5190
7
1143
7
3976
7
1605
7
2305
7
7327
7
2009
7
3138
7
4271
8
160
7
3945
7
6385
7
3349
8
90
7
1940
7
4087
7
5189
7
5301
7
5871
7
1525
7
7414
7
2336
7
6491
7
5960
7
3830
7
4270
7
564
7
5605
7
3430
7
815
7
687
7
...

output:

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

result:

ok 1000 lines

Test #11:

score: 100
Accepted
time: 61ms
memory: 9116kb

input:

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

output:

3357
3753
968
1481
2290
5183
875
3584
6004
4147
5498
3486
5857
5417
188
5915
3116
5427
7490
7532
6436
6332
6029
3776
5823
267
234
7011
6510
7586
5328
5243
6648
3546
5057
4140
411
4762
2738
2782
2343
1901
2608
3257
960
3456
4463
1381
3186
1277
5062
2131
1107
5236
1068
7032
603
247
5400
6082
6947
2375...

input:

decode
1000
7
3357
7
3753
7
968
7
1481
7
2290
7
5183
7
875
7
3584
7
6004
7
4147
7
5498
7
3486
7
5857
7
5417
8
188
7
5915
7
3116
7
5427
7
7490
7
7532
7
6436
7
6332
7
6029
7
3776
7
5823
7
267
8
234
7
7011
7
6510
7
7586
7
5328
7
5243
7
6648
7
3546
7
5057
7
4140
7
411
7
4762
7
2738
7
2782
7
2343
7
1901
...

output:

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

result:

ok 1000 lines

Test #12:

score: 100
Accepted
time: 54ms
memory: 9152kb

input:

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

output:

2993
2280
3538
3625
937
6598
5164
6844
2528
3254
3266
4555
1379
6492
159
6640
6051
2691
6122
4471
1556
749
1413
3362
6084
6535
6227
5157
4514
4294
3039
368
6192
6446
2132
520
2543
7729
5393
3012
1431
3975
5650
5854
2269
3911
5158
4300
1808
5484
5944
4367
7371
208
5304
6013
1548
5371
5290
1298
298
38...

input:

decode
1000
7
2993
7
2280
7
3538
7
3625
7
937
7
6598
7
5164
7
6844
7
2528
7
3254
7
3266
7
4555
7
1379
7
6492
8
159
7
6640
7
6051
7
2691
7
6122
7
4471
7
1556
7
749
7
1413
7
3362
7
6084
7
6535
7
6227
7
5157
7
4514
7
4294
7
3039
7
368
7
6192
7
6446
7
2132
7
520
7
2543
7
7729
7
5393
7
3012
7
1431
7
3975...

output:

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

result:

ok 1000 lines

Test #13:

score: 100
Accepted
time: 58ms
memory: 9140kb

input:

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

output:

2064
4610
7669
128
6324
7600
2803
4897
2867
2621
7725
1497
6094
5216
2952
5963
3317
6415
7700
1992
902
1363
1406
5369
1051
4183
5657
602
2129
5687
5080
5107
1120
2031
3306
1508
4819
3488
470
934
2345
2801
1528
6528
545
6979
948
7423
3260
2585
134
264
766
7196
1665
467
2583
4718
4109
465
2668
5025
50...

input:

decode
1000
7
2064
7
4610
7
7669
8
128
7
6324
7
7600
7
2803
7
4897
7
2867
7
2621
7
7725
7
1497
7
6094
7
5216
7
2952
7
5963
7
3317
7
6415
7
7700
7
1992
7
902
7
1363
7
1406
7
5369
7
1051
7
4183
7
5657
7
602
7
2129
7
5687
7
5080
7
5107
7
1120
7
2031
7
3306
7
1508
7
4819
7
3488
8
470
7
934
7
2345
7
2801...

output:

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

result:

ok 1000 lines

Test #14:

score: 100
Accepted
time: 72ms
memory: 9140kb

input:

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

output:

10350
2643
6848
5866
19983
39687
36864
36277
21869
8375
42845
27312
19055
2287
19648
21675
1569
27318
10289
30887
30280
4488
13926
30059
14984
2388
4815
34172
34004
2960
16422
30100
15469
41288
38200
15561
20278
33169
11272
26122
7623
8452
19980
23537
4279
25897
4483
27419
19398
27581
796
22650
4075...

input:

decode
1000
8
10350
8
2643
8
6848
8
5866
8
19983
8
39687
8
36864
8
36277
8
21869
8
8375
8
42845
8
27312
8
19055
8
2287
8
19648
8
21675
8
1569
8
27318
8
10289
8
30887
8
30280
8
4488
8
13926
8
30059
8
14984
8
2388
8
4815
8
34172
8
34004
8
2960
8
16422
8
30100
8
15469
8
41288
8
38200
8
15561
8
20278
8
...

output:

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

result:

ok 1000 lines

Test #15:

score: 100
Accepted
time: 69ms
memory: 9116kb

input:

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

output:

210378
244196
111680
243675
35142
17445
234743
50516
105301
236560
111627
53862
240730
161349
110771
81296
63220
130645
11644
204112
112848
170293
42025
164613
26203
24165
152650
172483
41103
140117
236979
100345
115048
150389
980
118602
33690
102681
50942
15891
66361
97241
147307
154190
179104
6103...

input:

decode
1000
9
210378
9
244196
9
111680
9
243675
9
35142
9
17445
9
234743
9
50516
9
105301
9
236560
9
111627
9
53862
9
240730
9
161349
9
110771
9
81296
9
63220
9
130645
9
11644
9
204112
9
112848
9
170293
9
42025
9
164613
9
26203
9
24165
9
152650
9
172483
9
41103
9
140117
9
236979
9
100345
9
115048
9
...

output:

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

result:

ok 1000 lines

Test #16:

score: 100
Accepted
time: 91ms
memory: 9124kb

input:

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

output:

1
1430715
537508
715358
140745
225948
1193808
1429008
931169
286087
785997
1017558
351383
239738
354664
311193
312988
453663
790728
994492
463117
905895
1316533
1267152
24581
1063106
984872
786699
1382780
1413582
895686
79241
1137939
504732
187122
1401831
813222
554636
525122
300893
366857
870237
78...

input:

decode
1000
10
1
10
1430715
10
537508
10
715358
10
140745
10
225948
10
1193808
10
1429008
10
931169
10
286087
10
785997
10
1017558
10
351383
10
239738
10
354664
10
311193
10
312988
10
453663
10
790728
10
994492
10
463117
10
905895
10
1316533
10
1267152
10
24581
10
1063106
10
984872
10
786699
10
1382...

output:

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

result:

ok 1000 lines

Test #17:

score: 100
Accepted
time: 107ms
memory: 9052kb

input:

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

output:

1
8414640
3138808
4207321
3522476
4703864
4846787
5266805
5500362
4643861
1987996
4449676
6450788
972419
5509895
2543997
2224999
1259295
5683958
1413141
2877498
8128441
5157716
1486743
2192805
5823002
8073335
8394987
584239
4429230
6125917
5772487
2949583
3269058
8388306
457932
4635581
352582
207044...

input:

decode
1000
11
1
11
8414640
11
3138808
11
4207321
11
3522476
11
4703864
11
4846787
11
5266805
11
5500362
11
4643861
11
1987996
11
4449676
11
6450788
11
972419
11
5509895
11
2543997
11
2224999
11
1259295
11
5683958
11
1413141
11
2877498
11
8128441
11
5157716
11
1486743
11
2192805
11
5823002
11
807333...

output:

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

result:

ok 1000 lines

Test #18:

score: 100
Accepted
time: 113ms
memory: 9036kb

input:

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

output:

1
50067108
18565648
25033555
35028685
24323099
44825854
21477529
27289203
24577427
47564583
15937727
9946338
4501213
31300635
4999014
279154
20968362
33204335
14336745
38337323
38963490
18571664
8631868
30864813
37846763
30150502
45027410
49281211
24973308
9774747
38397480
7559985
26729118
1809901
1...

input:

decode
1000
12
1
12
50067108
12
18565648
12
25033555
12
35028685
12
24323099
12
44825854
12
21477529
12
27289203
12
24577427
12
47564583
12
15937727
12
9946338
12
4501213
12
31300635
12
4999014
12
279154
12
20968362
12
33204335
12
14336745
12
38337323
12
38963490
12
18571664
12
8631868
12
30864813
1...

output:

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

result:

ok 1000 lines

Test #19:

score: 100
Accepted
time: 132ms
memory: 9056kb

input:

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

output:

276760187
134809903
86865303
263865987
49462893
205673057
93583219
12212269
110223755
178158827
195352960
62437336
64227969
31655176
252916075
172059091
49489188
93065727
205226277
152429788
120524122
99764873
174099594
52192259
257494006
57163055
258238535
80887538
222773182
54370652
288251926
1005...

input:

decode
1000
13
276760187
13
134809903
13
86865303
13
263865987
13
49462893
13
205673057
13
93583219
13
12212269
13
110223755
13
178158827
13
195352960
13
62437336
13
64227969
13
31655176
13
252916075
13
172059091
13
49489188
13
93065727
13
205226277
13
152429788
13
120524122
13
99764873
13
174099594...

output:

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

result:

ok 1000 lines

Test #20:

score: 100
Accepted
time: 150ms
memory: 9188kb

input:

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

output:

1
1822766520
669682580
911383261
717606150
1097898904
12327982
1499648915
1377918541
1186758759
731217805
1499277310
520544542
1506477089
812380858
445973535
729613836
1380846780
646968532
536901803
70123126
924215438
36516912
1174050887
102977674
603306287
368085644
1001524430
1402074871
788545936
...

input:

decode
1000
14
1
14
1822766520
14
669682580
14
911383261
14
717606150
14
1097898904
14
12327982
14
1499648915
14
1377918541
14
1186758759
14
731217805
14
1499277310
14
520544542
14
1506477089
14
812380858
14
445973535
14
729613836
14
1380846780
14
646968532
14
536901803
14
70123126
14
924215438
14
3...

output:

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

result:

ok 1000 lines

Test #21:

score: 100
Accepted
time: 173ms
memory: 9152kb

input:

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

output:

6425124985
105210526
5454943577
2964749896
8134228988
920387119
986674273
2820643319
9506148458
10156164122
5285653116
10827774917
5224939987
5091892296
6511326033
9678212385
4484694387
9054161640
3047325937
10774632541
5287863063
1671186271
7171501937
8208250437
6131864635
8308390364
9151854077
870...

input:

decode
1000
15
6425124985
15
105210526
15
5454943577
15
2964749896
15
8134228988
15
920387119
15
986674273
15
2820643319
15
9506148458
15
10156164122
15
5285653116
15
10827774917
15
5224939987
15
5091892296
15
6511326033
15
9678212385
15
4484694387
15
9054161640
15
3047325937
15
10774632541
15
52878...

output:

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

result:

ok 1000 lines

Test #22:

score: 100
Accepted
time: 186ms
memory: 9188kb

input:

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

output:

1
68328754959
24931096954
34164377480
56484756273
11843406353
30757520626
65936331393
34289423729
38090676860
18056661859
22808466941
61181409533
53381843765
142613791
58359972906
42577928528
19186841721
6387154106
12183669974
47175250027
30257325991
51794452587
21527235858
54179717020
7562000185
29...

input:

decode
1000
16
1
16
68328754959
16
24931096954
16
34164377480
16
56484756273
16
11843406353
16
30757520626
16
65936331393
16
34289423729
16
38090676860
16
18056661859
16
22808466941
16
61181409533
16
53381843765
16
142613791
16
58359972906
16
42577928528
16
19186841721
16
6387154106
16
12183669974
1...

output:

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

result:

ok 1000 lines

Test #23:

score: 100
Accepted
time: 210ms
memory: 9100kb

input:

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

output:

419555004681
284596155081
229196353104
416400814276
243472655584
148756179218
279879505377
107226106631
112746752720
159629875959
341445563821
311541957031
159527399262
226903091609
136318396219
13604651598
70002995581
199530114925
131168608669
89739398402
103686560481
309018771392
280639758846
3894...

input:

decode
1000
17
419555004681
17
284596155081
17
229196353104
17
416400814276
17
243472655584
17
148756179218
17
279879505377
17
107226106631
17
112746752720
17
159629875959
17
341445563821
17
311541957031
17
159527399262
17
226903091609
17
136318396219
17
13604651598
17
70002995581
17
199530114925
17...

output:

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

result:

ok 1000 lines

Test #24:

score: 100
Accepted
time: 234ms
memory: 9196kb

input:

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

output:

1
2619631042665
950718737673
1309815521333
2233361659205
1505032642392
737851554749
1861477178850
783709129261
1074001929815
643644602903
589714772126
998488374187
469882079935
991435548575
1662639265696
2585503205418
1025803677559
1636354141315
864520949063
370994078974
1414984319404
936109324515
6...

input:

decode
1000
18
1
18
2619631042665
18
950718737673
18
1309815521333
18
2233361659205
18
1505032642392
18
737851554749
18
1861477178850
18
783709129261
18
1074001929815
18
643644602903
18
589714772126
18
998488374187
18
469882079935
18
991435548575
18
1662639265696
18
2585503205418
18
1025803677559
18...

output:

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

result:

ok 1000 lines

Test #25:

score: 100
Accepted
time: 248ms
memory: 9248kb

input:

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

output:

1
16332922290300
5914230186933
8166461145151
6766237723049
3243151856317
5887216993806
15484310404537
6817834894178
3938504018755
12421424908457
12299564756521
1983229130303
14807285159732
10686436025188
13522162532557
15523643380833
1341503702239
6699342058885
2417411214981
15030934550329
822094358...

input:

decode
1000
19
1
19
16332922290300
19
5914230186933
19
8166461145151
19
6766237723049
19
3243151856317
19
5887216993806
19
15484310404537
19
6817834894178
19
3938504018755
19
12421424908457
19
12299564756521
19
1983229130303
19
14807285159732
19
10686436025188
19
13522162532557
19
15523643380833
19
...

output:

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

result:

ok 1000 lines

Test #26:

score: 100
Accepted
time: 279ms
memory: 9108kb

input:

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

output:

19498080322313
49817054838033
101664274656323
100627116401029
76711767305612
50256026942631
27446019662868
78685197898968
67824364564124
49916724087666
79348540861537
78218156553374
36488012498918
28254845242853
17787442696576
19988243920433
3638936792378
86225660310193
18197491624905
56793612832354...

input:

decode
1000
20
19498080322313
20
49817054838033
20
101664274656323
20
100627116401029
20
76711767305612
20
50256026942631
20
27446019662868
20
78685197898968
20
67824364564124
20
49916724087666
20
79348540861537
20
78218156553374
20
36488012498918
20
28254845242853
20
17787442696576
20
1998824392043...

output:

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

result:

ok 1000 lines

Test #27:

score: 100
Accepted
time: 309ms
memory: 9156kb

input:

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

output:

457891657785452
376852450991272
419156106614045
158275162968218
57044171408718
466511895075308
551982198129398
255248802071526
355189989867074
74725588658252
142851035009195
82087566090069
297733670379399
494786742857265
532337562653469
245616295633689
10890128472382
13698304438294
294857152286474
1...

input:

decode
1000
21
457891657785452
21
376852450991272
21
419156106614045
21
158275162968218
21
57044171408718
21
466511895075308
21
551982198129398
21
255248802071526
21
355189989867074
21
74725588658252
21
142851035009195
21
82087566090069
21
297733670379399
21
494786742857265
21
532337562653469
21
245...

output:

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

result:

ok 1000 lines

Test #28:

score: 100
Accepted
time: 334ms
memory: 9204kb

input:

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

output:

1549097233741187
2348692793632827
3539631530026523
3436910956185406
2639420574812571
2472724399429846
3146903190436063
1439701099158870
2531818215527353
988367601083650
3035761471386141
325743632807258
3532017874273883
946552538232123
3578925811281954
2783843672188548
448236778303292
834991227263707...

input:

decode
1000
22
1549097233741187
22
2348692793632827
22
3539631530026523
22
3436910956185406
22
2639420574812571
22
2472724399429846
22
3146903190436063
22
1439701099158870
22
2531818215527353
22
988367601083650
22
3035761471386141
22
325743632807258
22
3532017874273883
22
946552538232123
22
35789258...

output:

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

result:

ok 1000 lines

Test #29:

score: 100
Accepted
time: 365ms
memory: 9156kb

input:

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

output:

21850186409345844
5215578042248568
4648307064245094
25094951113259629
21497492218013558
20505248210446941
23805105670257708
22644577498608480
17227980640920600
16274088926465055
13702651481497480
15851516884272700
23468778544596257
11052226650931348
9923598486847784
7979643823692266
2282163605755833...

input:

decode
1000
23
21850186409345844
23
5215578042248568
23
4648307064245094
23
25094951113259629
23
21497492218013558
23
20505248210446941
23
23805105670257708
23
22644577498608480
23
17227980640920600
23
16274088926465055
23
13702651481497480
23
15851516884272700
23
23468778544596257
23
11052226650931...

output:

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

result:

ok 1000 lines

Test #30:

score: 100
Accepted
time: 395ms
memory: 9284kb

input:

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

output:

63790271477917971
7875653726956631
56059133815323940
63464578894025142
103962890367517896
132716543580994062
48162392032595262
45962235375606495
156959900974691635
38117855316278180
119169323762669048
113313660983140781
97145595630610385
75959640918800103
135478952447653366
42810060404146463
1083301...

input:

decode
1000
24
63790271477917971
24
7875653726956631
24
56059133815323940
24
63464578894025142
24
103962890367517896
24
132716543580994062
24
48162392032595262
24
45962235375606495
24
156959900974691635
24
38117855316278180
24
119169323762669048
24
113313660983140781
24
97145595630610385
24
75959640...

output:

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

result:

ok 1000 lines

Test #31:

score: 100
Accepted
time: 418ms
memory: 9204kb

input:

encode
1000
25
(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)(|)
25
(((((((((((((((((((((((((|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)|)
25
(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|(|)))))))))))))))))))))))))
25
((|)|((((|(|((|)|(|)(|))))|)|)(((|)(|)((|)|)|(|)...

output:

1
1031147983159782228
369779305096781526
515573991579891115
1007420886973509246
909859217597655979
72592873114887392
186235565842963261
646048257753452042
116890148228024438
376789860363694150
287388683121576458
866638559791364037
531209011855622834
771631836125358468
552254694266089124
623931182193...

input:

decode
1000
25
1
25
1031147983159782228
25
369779305096781526
25
515573991579891115
25
1007420886973509246
25
909859217597655979
25
72592873114887392
25
186235565842963261
25
646048257753452042
25
116890148228024438
25
376789860363694150
25
287388683121576458
25
866638559791364037
25
531209011855622...

output:

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

result:

ok 1000 lines

Test #32:

score: 100
Accepted
time: 347ms
memory: 9216kb

input:

encode
1000
25
(|)(((|(|(|(|))))|(|((|)(|)|)(|(|(|(|(|))))))(|))|(|((|)|)(|((|)|)((|)|))))
25
((|)(|(|((((|)|)|)|((|)|)(|))((((|(|))|)|)((|)|)|)(|(|(|)))))|(|(|)(|(|))))
22
(|(|(|(|((((|)|)|)(((|(((|)|)|))|(((|)|)|)(|))(|(|(|(|))))|)|)))))
24
((|(|))|(|(((|)(|)|(|))(((|)(|)|)(((|)|)(|)|((|)(|)|))(|)...

output:

113480751545553070
764807304235497873
1459403880951016
90935044243478676
123030570427359293
2629403081742911
547286440910028
44049032839509
60274947363694
9610845870469215
13240032997381448
67458825325057260
189345174887628402
862119653664762570
12668430214802448
34623028159682158
1
834118310619455
...

input:

decode
1000
25
113480751545553070
25
764807304235497873
22
1459403880951016
24
90935044243478676
24
123030570427359293
23
2629403081742911
21
547286440910028
20
44049032839509
20
60274947363694
23
9610845870469215
23
13240032997381448
24
67458825325057260
25
189345174887628402
25
862119653664762570
...

output:

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

result:

ok 1000 lines