QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#295608#4824. Bracket-and-bar Sequencesiee0 1ms3556kbC++141.8kb2023-12-31 16:30:452023-12-31 16:30:45

Judging History

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

  • [2023-12-31 16:30:45]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3556kb
  • [2023-12-31 16:30:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 25;
ll f[N + 1];
string decode(int n, ll val) {
	if (!n) return "";
	for (int u = 0; u < n; u++) {
		for (int v = 0; v < n - u; v++) {
			int w = n - u - v - 1;
			if (val < f[u] * f[v] * f[w]) {
				ll vw = val % f[w];
				val /= f[w];
				ll vv = val % f[v];
				val /= f[v];
				ll vu = val;
				assert(val < f[u]);
				return "("s + decode(u, vu) + "|" + decode(v, vv) + ")" + decode(w, vw);
			}
			val -= f[u] * f[v] * f[w];
		}
	}
	assert(false);
}
ll encode(int n, string s) {
	if (!n) return 0;
	int p = -1, q = -1;
	for (int i = 1, cur = 0; i < s.size(); i++) {
		if (s[i] == '(') cur++;
		if (s[i] == ')') cur--;
		if (cur == 0 && s[i] == '|') p = i;
		if (cur == -1 && s[i] == ')') {
			q = i;
			break;
		}
	}
	assert(p != -1 && q != -1);
	int U = p / 3, V = (q - p) / 3;
	ll ans = 0;
	for (int u = 0; u <= U; u++) {
		for (int v = 0; v < n - u; v++) {
			int w = n - 1 - u - v;
			if (u == U && v == V) {
				ll val = encode(u, s.substr(1, p - 1));
				val *= f[v];
				val += encode(v, s.substr(p + 1, q - (p + 1)));
				val *= f[w];
				val += encode(w, s.substr(q + 1, s.size() - (q + 1)));
				ans += val;
				return ans;
			}
			ans += f[u] * f[v] * f[w];
		}
	}
	assert(false);
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	for (int n = f[0] = 1; n <= N; n++) {
		for (int u = 0; u < n; u++) {
			for (int v = 0; v < n - u; v++) {
				f[n] += f[u] * f[v] * f[n - 1 - u];
			}
		}
	}
	string phase;
	cin >> phase;
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		if (phase == "encode") {
			string s;
			cin >> s;
			cout << encode(n, s) << "\n";
		} else {
			ll val;
			cin >> val;
			cout << decode(n, val) << "\n";
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

0
70
551

input:

decode
3
1
0
4
70
5
551

output:

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

result:

ok 3 lines

Test #2:

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

input:

encode
1
1
(|)

output:

0

input:

decode
1
1
0

output:

(|)

result:

ok single line: '(|)'

Test #3:

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

input:

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

output:

2
0
1

input:

decode
3
2
2
1
0
2
1

output:

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

result:

ok 3 lines

Test #4:

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

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:

0
1
2
3
4
5
6
7
8
9
10
11
0
1
2
3
4
5
6
7
8
9
10
11
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
0
1
2
3
4
5
6
7
8
9
10
11
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
46
47
48
49
50
51
52
53
54
55
56
57
58
...

input:

decode
1000
3
0
3
1
3
2
3
3
3
4
3
5
3
6
3
7
3
8
3
9
3
10
3
11
4
0
4
1
4
2
4
3
4
4
4
5
4
6
4
7
4
8
4
9
4
10
4
11
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
46
4
47
4
48
4
49
4
50
4
51
4
52
4
53
4
54
4
55
4
56
4
57
4
58
4
59
4
60
4
61
4
62
4
63
4
64
4
6...

output:

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

result:

ok 1000 lines

Test #5:

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

input:

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

output:

309743
309752
309753
309754
309755
309756
309757
309758
309759
309760
309761
309762
309763
309772
309773
309774
309775
309776
309777
309778
309779
309780
309781
309782
309783
309792
309793
309794
309795
309796
309797
309798
309799
309800
309801
309802
309803
309804
309805
309806
309807
309808
309809...

input:

decode
1000
6
309743
6
309752
6
309753
6
309754
6
309755
6
309756
6
309757
6
309758
6
309759
6
309760
6
309761
6
309762
6
309763
6
309772
6
309773
6
309774
6
309775
6
309776
6
309777
6
309778
6
309779
6
309780
6
309781
6
309782
6
309783
6
309792
6
309793
6
309794
6
309795
6
309796
6
309797
6
309798
...

output:

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

result:

ok 1000 lines

Test #6:

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

input:

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

output:

189256598750
189256906622
94628450806
189256284934
618954
189257523281
189256907311
307397
189255668564
615933
94627833675
189255976528
1153
189256286728
94628450760
94628759378
94627836101
189256286865
94628452700
189255977264
94628758796
94627836777
189256906698
189257525614
189257215782
189255668...

input:

decode
1000
7
189256598750
7
189256906622
7
94628450806
7
189256284934
7
618954
7
189257523281
7
189256907311
8
307397
7
189255668564
7
615933
7
94627833675
7
189255976528
8
1153
7
189256286728
7
94628450760
7
94628759378
7
94627836101
7
189256286865
7
94628452700
7
189255977264
7
94628758796
7
9462...

output:

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

result:

ok 1000 lines

Test #7:

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

input:

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

output:

94628142903
189257521965
94627525746
309808
94628759279
618928
189256289943
189256283876
309180
189256287108
309106
189256285116
307948
548
189255668037
94627834112
94627833557
189256292579
307389
308057
189256291954
94628450823
189256907301
189257523222
189256287623
189255975464
94628760751
9462752...

input:

decode
1000
7
94628142903
7
189257521965
7
94627525746
7
309808
7
94628759279
7
618928
7
189256289943
7
189256283876
7
309180
7
189256287108
7
309106
7
189256285116
8
307948
8
548
7
189255668037
7
94627834112
7
94627833557
7
189256292579
8
307389
8
308057
7
189256291954
7
94628450823
7
189256907301
...

output:

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

result:

ok 1000 lines

Test #8:

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

input:

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

output:

189257522508
307903
189255667990
94627832493
189256287169
189256598790
94628761862
189256907349
549
94628450208
189257525589
94627525735
189255667489
189257523170
189256284404
618903
94628450234
189256287404
189256289799
189256292634
94628762490
189255667490
94627834066
94627836723
308051
1892575257...

input:

decode
1000
7
189257522508
7
307903
7
189255667990
7
94627832493
7
189256287169
7
189256598790
7
94628761862
7
189256907349
8
549
7
94628450208
7
189257525589
7
94627525735
7
189255667489
7
189257523170
7
189256284404
7
618903
7
94628450234
7
189256287404
7
189256289799
7
189256292634
7
94628762490
...

output:

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

result:

ok 1000 lines

Test #9:

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

input:

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

output:

189256287684
94627525825
308028
307878
94628762451
189256286883
189256289833
189257523196
94627525146
189257523249
189257214055
617226
189256292595
94627525713
189256287305
189256287740
617836
189256289777
189257215138
308043
94627834102
617343
94627836689
1184
189256289838
94628450262
617250
189256...

input:

decode
1000
7
189256287684
7
94627525825
7
308028
8
307878
7
94628762451
7
189256286883
7
189256289833
7
189257523196
7
94627525146
7
189257523249
7
189257214055
7
617226
7
189256292595
7
94627525713
7
189256287305
7
189256287740
7
617836
7
189256289777
7
189257215138
8
308043
7
94627834102
7
617343...

output:

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

result:

ok 1000 lines

Test #10:

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

input:

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

output:

189257523377
189257523050
309795
94628144054
617100
189256291978
94628761251
189256286848
617873
94627525124
94627831920
189256287093
617874
189255668023
94627525736
94627836181
189257523252
94627833741
94628452662
189255975385
1155
189255667984
189256906598
94628759908
591
94627833632
189255668644
...

input:

decode
1000
7
189257523377
7
189257523050
7
309795
7
94628144054
7
617100
7
189256291978
7
94628761251
7
189256286848
7
617873
7
94627525124
7
94627831920
7
189256287093
7
617874
7
189255668023
7
94627525736
7
94627836181
7
189257523252
7
94627833741
7
94628452662
7
189255975385
8
1155
7
18925566798...

output:

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

result:

ok 1000 lines

Test #11:

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

input:

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

output:

94628759924
94628762360
617141
94627524624
94627836158
189256287086
617000
94628760733
189256292633
189255668728
189256287753
94628760109
189256291960
189256287624
1191
189256292042
94628452624
189256287634
189257524419
189257524477
189256906673
189256906059
189256292674
94628762391
189256291448
130...

input:

decode
1000
7
94628759924
7
94628762360
7
617141
7
94627524624
7
94627836158
7
189256287086
7
617000
7
94628760733
7
189256292633
7
189255668728
7
189256287753
7
94628760109
7
189256291960
7
189256287624
8
1191
7
189256292042
7
94628452624
7
189256287634
7
189257524419
7
189257524477
7
189256906673
...

output:

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

result:

ok 1000 lines

Test #12:

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

input:

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

output:

94628451991
94627836148
94628760201
94628761252
617086
189257213384
189256286891
189257215136
94628143439
94628759303
94628759323
189255977199
619600
189256907215
1154
189257213442
189256292696
94628144136
189256599284
189255976613
94627525201
615894
619650
94628759929
189256598768
189256907274
1892...

input:

decode
1000
7
94628451991
7
94627836148
7
94628760201
7
94628761252
7
617086
7
189257213384
7
189256286891
7
189257215136
7
94628143439
7
94628759303
7
94628759323
7
189255977199
7
619600
7
189256907215
8
1154
7
189257213442
7
189256292696
7
94628144136
7
189256599284
7
189255976613
7
94627525201
7
...

output:

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

result:

ok 1000 lines

Test #13:

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

input:

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

output:

94627833988
189256283293
189257525602
645
189256600028
189257525047
94628450781
189256285094
94628450885
94628144034
189257525682
94627525118
189256598778
189256287143
94628451464
189256292576
94628759390
189256906644
189257525649
94627833716
617043
619576
619643
189256287392
617280
189255974803
189...

input:

decode
1000
7
94627833988
7
189256283293
7
189257525602
8
645
7
189256600028
7
189257525047
7
94628450781
7
189256285094
7
94628450885
7
94628144034
7
189257525682
7
94627525118
7
189256598778
7
189256287143
7
94628451464
7
189256292576
7
94628759390
7
189256906644
7
189257525649
7
94627833716
7
617...

output:

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

result:

ok 1000 lines

Test #14:

score: 0
Wrong Answer on the first run

input:

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

output:

7726663756690640579
94628144064
189257215148
189256291969
7726664040576012143
-2993415992557517616
-2993416181812872846
-2993416181812876485
-2993416560327946235
7726663662062500450
-2993415992555969137
-2993416371071046460
7726664040575393241
94627836155
7726664040575704263
-2993416560327947449
946...

input:


output:


result:

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