QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#295290#4824. Bracket-and-bar Sequencesucup-team1134#0 1ms3564kbC++201.3kb2023-12-31 02:05:392023-12-31 02:05:39

Judging History

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

  • [2023-12-31 02:05:39]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3564kb
  • [2023-12-31 02:05:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string SS;cin>>SS;
    int Q;cin>>Q;
    if(SS=="encode"){
        while(Q--){
            int N;cin>>N;
            string S;cin>>S;
            ll ans=0;
            for(char c:S){
                ans*=4;
                if(c=='(') ans+=1;
                if(c=='|') ans+=2;
                if(c==')') ans+=3;
            }
            cout<<ans<<"\n";
        }
    }else{
        while(Q--){
            int N;cin>>N;
            ll ans;cin>>ans;
            string S;
            while(ans){
                ll x=ans%4;ans/=4;
                if(x==1) S+='(';
                if(x==2) S+='|';
                if(x==3) S+=')';
            }
            reverse(all(S));
            cout<<S<<"\n";
        }
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

27
5618619
431843067

input:

decode
3
1
27
4
5618619
5
431843067

output:

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

result:

ok 3 lines

Test #2:

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

input:

encode
1
1
(|)

output:

27

input:

decode
1
1
27

output:

(|)

result:

ok single line: '(|)'

Test #3:

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

input:

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

output:

1467
27
1647

input:

decode
3
2
1467
1
27
2
1647

output:

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

result:

ok 3 lines

Test #4:

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

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:

112347
112239
112059
105435
105327
104895
104175
93915
93807
93627
91899
89019
7190235
7190127
7189947
7183323
7183215
7182783
7182063
7171803
7171695
7171515
7169787
7166907
6747867
6747759
6747579
6740955
6713307
6667227
6740847
6740415
6739695
6713199
6712767
6711039
6708159
6667119
6666687
66659...

input:

decode
1000
3
112347
3
112239
3
112059
3
105435
3
105327
3
104895
3
104175
3
93915
3
93807
3
93627
3
91899
3
89019
4
7190235
4
7190127
4
7189947
4
7183323
4
7183215
4
7182783
4
7182063
4
7171803
4
7171695
4
7171515
4
7169787
4
7166907
4
6747867
4
6747759
4
6747579
4
6740955
4
6713307
4
6667227
4
674...

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:

27208170351
27303721407
27303279039
27302541759
27275409855
27274967487
27273198015
27270248895
27228223935
27227781567
27227044287
27219966399
27208169919
27303720687
27303713775
27303702255
27303278319
27303271407
27303243759
27303197679
27302541039
27302534127
27302522607
27302412015
27302227695
...

input:

decode
1000
6
27208170351
6
27303721407
6
27303279039
6
27302541759
6
27275409855
6
27274967487
6
27273198015
6
27270248895
6
27228223935
6
27227781567
6
27227044287
6
27219966399
6
27208169919
6
27303720687
6
27303713775
6
27303702255
6
27303278319
6
27303271407
6
27303243759
6
27303197679
6
273025...

output:

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

result:

ok 1000 lines

Test #6:

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

input:

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

output:

1570241969775
1570270723515
1759690611135
1541788244955
1879507187451
1484833517307
1569390489531
120630319607547
1575563910075
1880043742971
1747632102255
1573683392367
120632056935867
1569524117211
1759258270143
1747610691327
1758503295963
1492214717295
1758147230655
1573391363823
1747739635695
17...

input:

decode
1000
7
1570241969775
7
1570270723515
7
1759690611135
7
1541788244955
7
1879507187451
7
1484833517307
7
1569390489531
8
120630319607547
7
1575563910075
7
1880043742971
7
1747632102255
7
1573683392367
8
120632056935867
7
1569524117211
7
1759258270143
7
1747610691327
7
1758503295963
7
1492214717...

output:

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

result:

ok 1000 lines

Test #7:

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

input:

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

output:

1767070088127
1493402609403
1768836274623
1882695597039
1747631627199
1879507926459
1492194662847
1541815383663
1882902161151
1492214281947
1882921037679
1570772859327
120630170089179
120632104546011
1575608577903
1742578054875
1766770710255
1492205158107
120630319627887
120629954870235
153947464879...

input:

decode
1000
7
1767070088127
7
1493402609403
7
1768836274623
7
1882695597039
7
1747631627199
7
1879507926459
7
1492194662847
7
1541815383663
7
1882902161151
7
1492214281947
7
1882921037679
7
1570772859327
8
120630170089179
8
120632104546011
7
1575608577903
7
1742578054875
7
1766770710255
7
1492205158...

output:

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

result:

ok 1000 lines

Test #8:

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

input:

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

output:

1492961310459
1882923558651
1575605958255
1759851944955
1492214247387
1569121562223
1745293663215
1569196981179
120632104545903
1759824419823
1470753070011
1768836281787
1575637935867
1472878540539
1493497657791
1879515438075
1759822376895
1484966489967
1569202084287
1491890597595
1742041104111
1575...

input:

decode
1000
7
1492961310459
7
1882923558651
7
1575605958255
7
1759851944955
7
1492214247387
7
1569121562223
7
1745293663215
7
1569196981179
8
120632104545903
7
1759824419823
7
1470753070011
7
1768836281787
7
1575637935867
7
1472878540539
7
1493497657791
7
1879515438075
7
1759822376895
7
148496648996...

output:

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

result:

ok 1000 lines

Test #9:

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

input:

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

output:

1541251511739
1768828596219
1882902163419
120630292617663
1741189520367
1484966966715
1541721003759
1484946894267
1768884198255
1491892551099
1541195939259
1879515567855
1472565309147
1768837012335
1539475664319
1493421504111
1879515557487
1570270845807
1539466260219
120629988388827
1745597953467
18...

input:

decode
1000
7
1541251511739
7
1768828596219
7
1882902163419
8
120630292617663
7
1741189520367
7
1484966966715
7
1541721003759
7
1484946894267
7
1768884198255
7
1491892551099
7
1541195939259
7
1879515567855
7
1472565309147
7
1768837012335
7
1539475664319
7
1493421504111
7
1879515557487
7
157027084580...

output:

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

result:

ok 1000 lines

Test #10:

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

input:

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

output:

1472751988155
1492213524219
1882700838639
1766690025327
1879516276479
1541279694555
1747409288175
1492969680603
1878628351599
1768879486575
1767100537791
1541287638747
1878439607919
1575610576623
1768829204187
1758369267675
1484380552635
1742611506939
1758360230847
1573463717595
120632056901595
1575...

input:

decode
1000
7
1472751988155
7
1492213524219
7
1882700838639
7
1766690025327
7
1879516276479
7
1541279694555
7
1747409288175
7
1492969680603
7
1878628351599
7
1768879486575
7
1767100537791
7
1541287638747
7
1878439607919
7
1575610576623
7
1768829204187
7
1758369267675
7
1484380552635
7
1742611506939
...

output:

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

result:

ok 1000 lines

Test #11:

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

input:

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

output:

1747441146303
1742605761519
1879949686491
1768911461307
1759173345243
1570278667707
1879969733595
1742575761855
1491892367067
1575538768827
1492961441211
1742530832127
1541204307675
1569522955707
120632056190703
1535882804955
1758348437247
1569202091739
1492189117371
1491810892731
1570240053243
1570...

input:

decode
1000
7
1747441146303
7
1742605761519
7
1879949686491
7
1768911461307
7
1759173345243
7
1570278667707
7
1879969733595
7
1742575761855
7
1491892367067
7
1575538768827
7
1492961441211
7
1742530832127
7
1541204307675
7
1569522955707
8
120632056190703
7
1535882804955
7
1758348437247
7
156920209173...

output:

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

result:

ok 1000 lines

Test #12:

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

input:

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

output:

1759249275903
1759221084123
1742522530671
1747407592431
1879969197807
1541739867579
1484966946555
1539466555131
1766950137711
1747629752175
1747629860607
1573491470319
1878739500987
1569515224059
120632056929243
1541715977979
1466445000411
1766734622703
1539474943599
1573659766719
1768878226287
1880...

input:

decode
1000
7
1759249275903
7
1759221084123
7
1742522530671
7
1747407592431
7
1879969197807
7
1541739867579
7
1484966946555
7
1539466555131
7
1766950137711
7
1747629752175
7
1747629860607
7
1573491470319
7
1878739500987
7
1569515224059
8
120632056929243
7
1541715977979
7
1466445000411
7
176673462270...

output:

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

result:

ok 1000 lines

Test #13:

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

input:

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

output:

1758503302587
1570807585215
1470751162299
120632098143087
1466445000303
1483623296955
1758503294703
1570776707007
1759249284975
1766768098239
1470412815291
1768884205167
1569201962607
1570731572187
1759688376255
1472879095515
1747605896127
1570270703355
1472559037371
1745631418815
1878761772783
1878...

input:

decode
1000
7
1758503302587
7
1570807585215
7
1470751162299
8
120632098143087
7
1466445000303
7
1483623296955
7
1758503294703
7
1570776707007
7
1759249284975
7
1766768098239
7
1470412815291
7
1768884205167
7
1569201962607
7
1570731572187
7
1759688376255
7
1472879095515
7
1747605896127
7
157027070335...

output:

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

result:

ok 1000 lines

Test #14:

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

input:

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

output:

112544239245039
120514021276527
120286695234555
120282420309723
111834197356527
95549975665659
100426794851259
100449448816059
100838967537087
113208284770047
94243856805819
95581736122815
111526773970671
120506474561499
111831208016319
100838781328239
120516134006511
95581702650303
112592557635003
...

input:

decode
1000
8
112544239245039
8
120514021276527
8
120286695234555
8
120282420309723
8
111834197356527
8
95549975665659
8
100426794851259
8
100449448816059
8
100838967537087
8
113208284770047
8
94243856805819
8
95581736122815
8
111526773970671
8
120506474561499
8
111831208016319
8
100838781328239
8
1...

output:

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

result:

ok 1000 lines

Test #15:

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

input:

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

output:

6428137670246331
6031490847535035
7148704342407615
6011834761927611
7694860840300143
7711680045176559
6031490986764027
7245074809681659
7137599568670575
6081791515159995
7148594800294335
7208352519797691
6080021587147707
6082422851353455
7137314844949359
7236683635211199
7202279765400507
64450354298...

input:

decode
1000
9
6428137670246331
9
6031490847535035
9
7148704342407615
9
6011834761927611
9
7694860840300143
9
7711680045176559
9
6031490986764027
9
7245074809681659
9
7137599568670575
9
6081791515159995
9
7148594800294335
9
7208352519797691
9
6080021587147707
9
6082422851353455
9
7137314844949359
9
7...

output:

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

result:

ok 1000 lines

Test #16:

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

input:

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

output:

494109216260077275
384307608006933435
461168601843367935
413024489492077503
492833645299432431
492505728371579835
411617286304818939
384325974146005947
391351092911107515
463684865609808891
412525473851988927
411757651226457531
461169222883929711
492499542168296379
458125705979782911
458167987186931...

input:

decode
1000
10
494109216260077275
10
384307608006933435
10
461168601843367935
10
413024489492077503
10
492833645299432431
10
492505728371579835
10
411617286304818939
10
384325974146005947
10
391351092911107515
10
463684865609808891
10
412525473851988927
10
411757651226457531
10
461169222883929711
10...

output:

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

result:

ok 1000 lines

Test #17:

score: 0
Wrong Answer on the first run

input:

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

output:

-5270498306774157605
6148921728110934971
-7378697629481304065
7986693506198779631
-7678938246088507457
7950795463957639151
6609975513881470715
7885492566271564799
7411640303673596351
7951586435716988351
-7252031406453573893
7955144467961069531
6444013242042522047
-5375683950471956741
733057552443971...

input:


output:


result:

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