QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55890#4612. 福若格斯CharlieVinnie100 ✓484ms50508kbC++203.8kb2022-10-15 15:36:422022-10-15 15:36:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-15 15:36:44]
  • 评测
  • 测评结果:100
  • 用时:484ms
  • 内存:50508kb
  • [2022-10-15 15:36:42]
  • 提交

answer

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(int i=a;i>=b;i--)
#define Fin(file) freopen(file,"r",stdin)
#define Fout(file) freopen(file,"w",stdout)
using namespace std;
const int N=4e6+5,mod=998244353; typedef long long ll;
int qpow(int x,int y){int res=1;while(y){if(y&1){res=1ll*res*x%mod;}x=1ll*x*x%mod;y>>=1;}return res;}
int cp[N],cpinv[N];
// 0:   0
// 1:   1
// 2:   -1
// 3:   1/2
// 4:  -1/2
// 5:   ↑
// 6:   ↓
// 7:   *
int getid(string s){
    if(s=="LL_RR") return 7; // *

    if(s=="L_LRR") return 5; // ↑
    if(s=="_LLRR") return 0; // 0
    if(s=="LRL_R") return 7; // *
    if(s=="LR_LR") return 0; // 0
    if(s=="_RLLR") return 2; // -1
    if(s=="R_LLR") return 0; // 0
    if(s=="LRRL_") return 1; // 1
    if(s=="LRR_L") return 0; // 0
    if(s=="LRLR_") return 0; // 0
    if(s=="LR_RL") return 4; // -1/2
    if(s=="_RLRL") return 2; // -1
    if(s=="R_LRL") return 0; // 0
    if(s=="RRL_L") return 1; // 1
    if(s=="RR_LL") return 0; // 0

    if(s=="LLR_R") return 6; // ↓
    if(s=="LLRR_") return 0; // 0
    if(s=="L_RLR") return 7; // *
    if(s=="LR_LR") return 0; // 0
    if(s=="LRRL_") return 1; // 1
    if(s=="LRR_L") return 0; // 0
    if(s=="_RLLR") return 2; // -1
    if(s=="R_LLR") return 0; // 0
    if(s=="_LRLR") return 0; // 0
    if(s=="RL_LR") return 3; // 1/2
    if(s=="RLRL_") return 1; // 1
    if(s=="RLR_L") return 0; // 0
    if(s=="R_RLL") return 2; // -1
    if(s=="RR_LL") return 0; // 0

    throw 404;
}
int C(int x,int y) { if(y<0||x<y) return 0; else return 1ll*cp[x]*cpinv[y]%mod*cpinv[x-y]%mod; }
int sum[N*2];
void solve(){
    int n,cnt[8]={0}; cin>>n; For(i,1,n) { string s; int x; cin>>s>>x; cnt[getid(s)]+=x; }
    // For(i,0,7) cout<<cnt[i]<<' ';  cout<<endl;
    int ans[4]={0}; int m=0; For(i,0,7) m+=cnt[i];
    For(i,-2*m-1,2*m) sum[i+N]=0;  For(i,-cnt[4],cnt[3]) sum[i+N]=(sum[i-1+N]+C(cnt[4]+cnt[3],cnt[4]+i))%mod;
    int zero=0; int pw0=qpow(2,cnt[5]+cnt[6]+cnt[7]);
    For(i,-cnt[2],cnt[1]){
        int u=C(cnt[2]+cnt[1],cnt[2]+i);
        ans[0]=(ans[0]+1ll*(sum[cnt[3]+N]-sum[min(cnt[3],2*(-i))+N]+mod)*pw0%mod*u)%mod;
        ans[1]=(ans[1]+1ll*sum[min(cnt[3],2*(-i)-1)+N]*pw0%mod*u)%mod;
        zero=(zero+1ll*(sum[min(cnt[3],2*(-i))+N]-sum[min(cnt[3],2*(-i)-1)+N]+mod)*u)%mod;
    }
    // cerr<<ans[0]<<' '<<ans[1]<<' '<<zero<<endl;
    For(i,-2*m-1,2*m) sum[i+N]=0;  For(i,-cnt[6],cnt[5]) sum[i+N]=(sum[i-1+N]+C(cnt[5]+cnt[6],cnt[6]+i))%mod;
    if(cnt[7]==0){
        // cerr<<"hey\n";
        ans[0]=(ans[0]+1ll*zero*(sum[cnt[5]+N]-sum[0+N]+mod))%mod;
        ans[1]=(ans[1]+1ll*zero*(sum[-1+N]+mod))%mod;
        ans[3]=(ans[3]+1ll*zero*(sum[0+N]-sum[-1+N]+mod))%mod;
    }
    else{
        int pw1=qpow(2,cnt[7]),pw2=qpow(2,cnt[7]-1);
        ans[0]=(ans[0]+1ll*zero*(sum[cnt[5]+N]-sum[min(cnt[5],1)+N]+mod)%mod*pw1)%mod;
        ans[1]=(ans[1]+1ll*zero*sum[-2+N]%mod*pw1)%mod;
        ans[0]=(ans[0]+1ll*zero*(sum[min(cnt[5],1)+N]-sum[0+N]+mod)%mod*pw2)%mod;
        ans[1]=(ans[1]+1ll*zero*(sum[-1+N]-sum[-2+N]+mod)%mod*pw2)%mod;
        ans[2]=(ans[2]+1ll*zero*(sum[min(cnt[5],1)+N]-sum[-2+N]+mod)%mod*pw2)%mod;
        ans[3]=(ans[3]+1ll*zero*(sum[0+N]-sum[-1+N]+mod)%mod*pw2)%mod;
    }
    For(i,0,3) ans[i]=1ll*ans[i]*qpow(2,cnt[0])%mod;
    // int ss=qpow(2,cnt[0]+cnt[1]+cnt[2]+cnt[3]+cnt[4]+cnt[5]+cnt[6]+cnt[7]);
    // ans[1]=(1ll*ss-ans[0]+mod-ans[2]+mod-ans[3]+mod)%mod;
    For(i,0,3) cout<<ans[i]<<' ';  cout<<'\n';
}
signed main(){
    cp[0]=1; For(i,1,N-5) cp[i]=1ll*cp[i-1]*i%mod;
    cpinv[N-5]=qpow(cp[N-5],mod-2); Rev(i,N-6,0) cpinv[i]=1ll*cpinv[i+1]*(i+1)%mod;
    int T,Charlie; cin>>Charlie>>T; while(T--) solve();
    cerr<<"Time = "<<clock()<<" ms"<<endl;
    return 0;
}

// START TYPING IF YOU DON'T KNOW WHAT TO DO

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 38ms
memory: 34860kb

input:

1 100
1
LLR_R 1
1
LLR_R 1
1
LRR_L 1
1
_RLRL 1
1
RLRL_ 1
1
LRR_L 1
1
R_LLR 1
1
LRR_L 1
1
L_RLR 1
1
L_RLR 1
1
RLR_L 1
1
LR_RL 1
1
R_RLL 1
1
LRL_R 1
1
R_LLR 1
1
_RLLR 1
1
_RLLR 1
1
_RLRL 1
1
_LLRR 1
1
RLR_L 1
1
LRL_R 1
1
R_RLL 1
1
LLR_R 1
1
L_RLR 1
1
R_LLR 1
1
RL_LR 1
1
RL_LR 1
1
LLRR_ 1
1
_RLRL 1
1
L_...

output:

0 1 0 1 
0 1 0 1 
0 0 0 2 
0 1 0 1 
1 0 0 1 
0 0 0 2 
0 0 0 2 
0 0 0 2 
0 0 1 1 
0 0 1 1 
0 0 0 2 
0 1 0 1 
0 1 0 1 
0 0 1 1 
0 0 0 2 
0 1 0 1 
0 1 0 1 
0 1 0 1 
0 0 0 2 
0 0 0 2 
0 0 1 1 
0 1 0 1 
0 1 0 1 
0 0 1 1 
0 0 0 2 
1 0 0 1 
1 0 0 1 
0 0 0 2 
0 1 0 1 
0 0 1 1 
0 0 0 2 
0 1 0 1 
0 0 0 2 
0 1...

result:

ok 400 numbers

Test #2:

score: 5
Accepted
time: 37ms
memory: 34752kb

input:

2 100
3
LLRR_ 1
LR_RL 1
RR_LL 1
1
_LRLR 1
4
LRR_L 1
RL_LR 1
R_LLR 1
R_LRL 1
5
LRL_R 1
LRRL_ 1
LR_LR 1
RL_LR 1
_RLRL 1
3
LLRR_ 1
LRR_L 1
RLR_L 1
2
LLR_R 1
L_LRR 1
4
LL_RR 1
LRL_R 1
R_LLR 1
_RLLR 1
4
LRRL_ 1
LR_RL 1
R_RLL 1
_RLRL 1
2
LRRL_ 1
LR_LR 1
5
LLRR_ 1
LRLR_ 1
LRRL_ 1
_RLLR 1
_RLRL 1
2
L_RLR 1
...

output:

0 4 0 4 
0 0 0 2 
8 0 0 8 
16 8 4 4 
0 0 0 8 
1 1 0 2 
0 8 4 4 
2 11 0 3 
2 0 0 2 
4 16 0 12 
0 0 2 2 
0 0 16 16 
2 0 0 2 
16 0 8 8 
20 8 0 4 
0 12 2 2 
24 0 0 8 
1 2 0 1 
0 2 0 2 
2 2 0 4 
10 2 0 4 
0 4 0 4 
13 2 0 1 
8 0 0 8 
0 4 2 2 
8 5 2 1 
4 16 8 4 
0 12 0 4 
16 4 8 4 
0 2 0 2 
0 0 0 2 
8 4 0 ...

result:

ok 400 numbers

Test #3:

score: 5
Accepted
time: 48ms
memory: 34876kb

input:

3 100
8
LRL_R 1
LRR_L 1
LR_LR 1
LR_RL 1
RLRL_ 1
RL_LR 1
R_LLR 1
R_RLL 1
8
LL_RR 1
LRRL_ 1
LR_RL 1
RLR_L 1
RRL_L 1
R_LRL 1
_LLRR 1
_LRLR 1
8
LLRR_ 1
LLR_R 1
LL_RR 1
LRR_L 1
LR_LR 1
R_LRL 1
_LLRR 1
_LRLR 1
8
LLRR_ 1
LLR_R 1
LRL_R 1
LR_LR 1
LR_RL 1
R_LLR 1
_RLLR 1
_RLRL 1
8
LL_RR 1
LRLR_ 1
L_LRR 1
L_RL...

output:

96 96 32 32 
192 32 16 16 
0 64 128 64 
0 232 16 8 
56 128 48 24 
96 64 64 32 
40 192 16 8 
128 64 32 32 
0 224 16 16 
16 208 16 16 
128 80 24 24 
192 16 32 16 
0 224 16 16 
176 48 0 32 
128 32 64 32 
192 16 32 16 
80 80 0 96 
16 176 32 32 
128 64 32 32 
32 200 16 8 
152 32 48 24 
80 80 64 32 
128 3...

result:

ok 400 numbers

Test #4:

score: 5
Accepted
time: 40ms
memory: 34964kb

input:

4 100
10
LLR_R 1
LL_RR 1
LRL_R 1
LRRL_ 1
LRR_L 1
LR_RL 1
L_LRR 1
L_RLR 1
R_RLL 1
_RLRL 1
10
LRL_R 1
LRRL_ 1
LR_RL 1
L_LRR 1
L_RLR 1
RLRL_ 1
R_LLR 1
R_RLL 1
_LLRR 1
_RLRL 1
10
LRL_R 1
LRR_L 1
L_LRR 1
L_RLR 1
RLRL_ 1
R_LLR 1
R_LRL 1
R_RLL 1
_RLLR 1
_RLRL 1
10
LLR_R 1
LL_RR 1
LRLR_ 1
LR_RL 1
L_LRR 1
L_...

output:

152 728 96 48 
368 512 96 48 
128 704 128 64 
416 416 128 64 
320 512 128 64 
320 416 192 96 
544 288 128 64 
512 192 160 160 
128 704 128 64 
0 896 64 64 
752 128 96 48 
288 544 128 64 
368 512 96 48 
832 64 64 64 
64 576 256 128 
256 512 128 128 
560 176 192 96 
512 368 96 48 
608 320 0 96 
512 19...

result:

ok 400 numbers

Test #5:

score: 5
Accepted
time: 204ms
memory: 50432kb

input:

5 100
1
LL_RR 838546
1
RRL_L 520881
1
LLRR_ 999980
1
RRL_L 2
1
RLRL_ 9
1
LRL_R 2
1
RL_LR 7
1
LLR_R 14
1
RLRL_ 753547
1
LRLR_ 17
1
LLR_R 722783
1
LR_LR 999985
1
LRL_R 999981
1
RLRL_ 431962
1
_LRLR 999992
1
LRRL_ 14
1
_RLLR 709382
1
RR_LL 999991
1
RL_LR 16
1
L_RLR 999992
1
LR_LR 13
1
L_RLR 999995
1
L_...

output:

0 0 50932616 50932616 
378274767 0 0 1 
0 0 0 242222522 
3 0 0 1 
511 0 0 1 
0 0 2 2 
127 0 0 1 
0 16383 0 1 
451252114 0 0 1 
0 0 0 131072 
0 462894643 0 1 
0 0 0 763410233 
0 0 242222522 242222522 
805483386 0 0 1 
0 0 0 886807583 
16383 0 0 1 
0 860243854 0 1 
0 0 0 942525968 
65535 0 0 1 
0 0 94...

result:

ok 400 numbers

Test #6:

score: 5
Accepted
time: 259ms
memory: 50352kb

input:

6 100
1
L_RLR 6
1
LR_LR 9
1
L_RLR 598544
1
_RLLR 11
1
LRR_L 999982
1
RL_LR 275578
1
L_LRR 489165
1
RRL_L 999987
1
_LLRR 15
1
RLR_L 28814
1
RR_LL 999983
1
R_RLL 999992
1
R_LRL 109447
1
LLRR_ 999987
1
LL_RR 11
1
RL_LR 999989
1
_LLRR 999985
1
LRLR_ 99274
1
RLR_L 609917
1
_LLRR 789302
1
LRL_R 1
1
_RLLR ...

output:

0 0 32 32 
0 0 0 512 
0 0 563598354 563598354 
0 2047 0 1 
0 0 0 968890088 
172890601 0 0 1 
840438312 0 0 1 
58907872 0 0 1 
0 0 0 32768 
0 0 0 569958573 
0 0 0 939535823 
0 886807582 0 1 
0 0 0 2446897 
0 0 0 58907873 
0 0 1024 1024 
235631491 0 0 1 
0 0 0 763410233 
0 0 0 380698432 
0 0 0 8426903...

result:

ok 400 numbers

Test #7:

score: 5
Accepted
time: 39ms
memory: 34904kb

input:

7 100
1
R_LRL 500
2
RLR_L 320
R_RLL 180
2
RR_LL 261
R_LRL 239
1
RR_LL 500
3
RLR_L 278
RRL_L 199
RR_LL 23
4
RLR_L 52
RRL_L 205
RR_LL 232
R_LRL 11
1
RRL_L 500
1
RRL_L 500
2
RRL_L 276
R_RLL 224
1
R_LRL 500
3
RRL_L 23
R_LRL 154
R_RLL 323
2
RLR_L 185
R_RLL 315
3
RR_LL 141
R_LRL 42
R_RLL 317
3
RLR_L 96
RR...

output:

0 0 0 616118644 
0 997240333 0 617122664 
0 0 0 616118644 
0 0 0 616118644 
684067419 0 0 930295578 
8875191 0 0 607243453 
616118643 0 0 1 
616118643 0 0 1 
537776684 201371198 0 875215115 
0 0 0 616118644 
795839458 220997578 0 597525961 
0 99297351 0 516821293 
0 736474409 0 877888588 
0 0 0 6161...

result:

ok 400 numbers

Test #8:

score: 5
Accepted
time: 358ms
memory: 44184kb

input:

8 100
3
RLR_L 245574
RRL_L 154512
R_LRL 199914
2
RLR_L 507948
RRL_L 92052
3
RR_LL 62618
R_LRL 75910
R_RLL 461472
2
RLR_L 584457
RR_LL 15543
3
RRL_L 199727
R_LRL 267713
R_RLL 132560
4
RLR_L 93412
RRL_L 204396
RR_LL 261031
R_LRL 41161
5
RLR_L 205717
RRL_L 55856
RR_LL 37924
R_LRL 156194
R_RLL 144309
3
...

output:

589933168 0 0 64289885 
372141343 0 0 282081710 
0 200036663 0 454186390 
0 0 0 654223053 
530840957 112226214 0 11155882 
394133210 0 0 260089843 
945425698 467886576 0 239155132 
170651780 433193248 0 50378025 
804125194 0 0 848342212 
0 599201709 0 55021344 
0 0 0 654223053 
681848735 44767448 0 ...

result:

ok 400 numbers

Test #9:

score: 5
Accepted
time: 37ms
memory: 34808kb

input:

9 100
16
LRLR_ 1
LRRL_ 9
LRR_L 2
LR_LR 6
LR_RL 8
RLRL_ 1
RLR_L 10
RL_LR 3
RRL_L 10
RR_LL 4
R_LLR 5
R_LRL 10
R_RLL 4
_LRLR 1
_RLLR 15
_RLRL 11
1
RR_LL 100
16
LRLR_ 7
LRRL_ 9
LRR_L 6
LR_LR 3
LR_RL 10
RLRL_ 9
RLR_L 6
RL_LR 8
RRL_L 4
RR_LL 5
R_LLR 2
R_LRL 5
R_RLL 9
_LRLR 2
_RLLR 8
_RLRL 7
6
LRR_L 15
LR_...

output:

404444034 391392352 0 86663332 
0 0 0 882499718 
131959415 927271783 0 821512873 
474227274 67875396 0 340397048 
523009412 174432988 0 185057318 
519149019 916510610 0 445084442 
78002240 460795054 0 343702424 
0 0 0 882499718 
766865590 441249859 0 672628622 
653955650 386822154 0 839966267 
12768...

result:

ok 400 numbers

Test #10:

score: 5
Accepted
time: 423ms
memory: 45900kb

input:

10 100
1
_LRLR 700000
1
RLR_L 700000
16
LRLR_ 48839
LRRL_ 44669
LRR_L 84201
LR_LR 51510
LR_RL 83993
RLRL_ 18715
RLR_L 25237
RL_LR 72656
RRL_L 29299
RR_LL 9204
R_LLR 14056
R_LRL 6221
R_RLL 19193
_LRLR 118525
_RLLR 71307
_RLRL 2375
16
LRLR_ 29471
LRRL_ 120527
LRR_L 14969
LR_LR 67351
LR_RL 66814
RLRL_ ...

output:

0 0 0 702777662 
0 0 0 702777662 
332242024 821001879 0 547778112 
335337504 37938615 0 329501543 
118490378 714032319 0 868499318 
831255045 305910895 0 563856075 
0 705279817 0 995742198 
982523351 906099528 0 810643489 
398014437 109520096 0 195243129 
0 0 0 702777662 
486613555 369377464 0 84503...

result:

ok 400 numbers

Test #11:

score: 5
Accepted
time: 36ms
memory: 34872kb

input:

11 100
16
LLRR_ 1
LRLR_ 1
LRR_L 1
LR_LR 1
LR_RL 1
L_RLR 1
RLRL_ 1
RLR_L 1
RRL_L 1
RR_LL 1
R_LLR 1
R_LRL 1
R_RLL 1
_LLRR 1
_RLLR 1
_RLRL 1
1
LRLR_ 16
5
LRLR_ 1
LRL_R 5
RR_LL 1
R_LLR 4
R_LRL 5
14
LLRR_ 1
LRLR_ 1
LRL_R 1
LRRL_ 1
LRR_L 1
LR_LR 1
LR_RL 1
L_RLR 1
RLRL_ 1
RL_LR 1
R_RLL 3
_LRLR 1
_RLLR 1
_R...

output:

12288 43008 5120 5120 
0 0 0 65536 
0 0 32768 32768 
6784 53376 2688 2688 
42368 14848 4160 4160 
65483 10 0 43 
0 0 0 65536 
0 0 0 65536 
0 61440 2048 2048 
32768 0 0 32768 
0 0 0 65536 
27648 27648 5120 5120 
12288 43008 5120 5120 
32 65152 176 176 
38400 16896 5120 5120 
37888 17408 5120 5120 
0 ...

result:

ok 400 numbers

Test #12:

score: 5
Accepted
time: 411ms
memory: 47228kb

input:

12 100
7
LR_LR 157600
RLRL_ 17039
RLR_L 213866
RRL_L 150323
R_LLR 113530
R_RLL 112238
_RLRL 35404
2
LRL_R 75922
LRR_L 724078
2
LR_RL 690984
RL_LR 109016
9
LRLR_ 128359
LR_RL 47906
RLR_L 167269
RL_LR 51548
RR_LL 145556
R_LLR 50595
R_RLL 27503
_LLRR 51843
_RLRL 129421
20
LLRR_ 38165
LRLR_ 17214
LRL_R ...

output:

940802264 171318240 0 480349095 
0 0 297112623 297112623 
747010002 552206767 0 293252830 
324891631 460789163 0 806788805 
272500237 228650626 545659368 545659368 
320812140 0 136706553 136706553 
530270951 0 0 63954295 
338739530 349282822 951345800 951345800 
766080882 144707713 340840502 3408405...

result:

ok 400 numbers

Test #13:

score: 5
Accepted
time: 44ms
memory: 34960kb

input:

13 100
10
LLR_R 2
LRRL_ 3
LRR_L 1
LR_RL 1
L_LRR 1
RLRL_ 1
RR_LL 2
R_LRL 1
_LLRR 1
_LRLR 1
14
LRLR_ 1
LRL_R 1
LRRL_ 1
LRR_L 1
L_LRR 1
L_RLR 1
RLRL_ 1
RRL_L 1
RR_LL 1
R_LLR 1
R_LRL 1
R_RLL 1
_LLRR 1
_LRLR 1
7
LLR_R 2
LRLR_ 2
LR_LR 2
L_LRR 2
R_LLR 3
_LLRR 1
_RLLR 2
14
LLR_R 1
LRRL_ 1
LRR_L 1
LR_LR 1
LR...

output:

15424 768 0 192 
12288 1024 2048 1024 
1280 13568 0 1536 
9792 4672 1280 640 
10112 4352 1280 640 
4096 10240 1536 512 
8192 5888 1536 768 
2048 12032 1536 768 
13568 1280 1024 512 
0 0 0 16384 
15876 396 88 24 
0 0 8192 8192 
2048 12288 1024 1024 
0 0 0 16384 
14912 320 576 576 
2048 12800 1024 512...

result:

ok 400 numbers

Test #14:

score: 5
Accepted
time: 458ms
memory: 48948kb

input:

14 100
7
LRLR_ 205240
LRL_R 78053
LRR_L 117478
LR_LR 181169
L_LRR 123470
RLR_L 38145
RL_LR 156445
9
LRL_R 49578
LRRL_ 133473
LRR_L 99644
RLR_L 98826
RL_LR 78104
RR_LL 41245
R_LLR 96478
R_LRL 43326
_LLRR 259326
7
LLRR_ 226267
LRLR_ 103046
L_RLR 25019
RLRL_ 82826
RLR_L 76224
RRL_L 242226
R_LRL 144392
...

output:

815679376 0 928130740 619889036 
194353719 0 585550540 585550540 
198024949 0 583714925 583714925 
168935695 886558158 0 309960946 
613456471 348504046 747623136 654115499 
895483140 623073264 368961478 476181270 
88353558 648410782 813467406 813467406 
0 0 183605223 183605223 
0 0 0 367210446 
9177...

result:

ok 400 numbers

Test #15:

score: 5
Accepted
time: 20ms
memory: 34868kb

input:

15 100
12
LLRR_ 1
LLR_R 1
LRRL_ 1
LRR_L 1
L_LRR 1
RLRL_ 1
RRL_L 1
RR_LL 1
R_LRL 1
_LRLR 1
_RLLR 1
_RLRL 1
5
LLRR_ 4
LLR_R 1
LRL_R 1
RL_LR 3
R_LLR 3
12
LLRR_ 1
LLR_R 1
LL_RR 1
LRL_R 1
LR_LR 1
LR_RL 1
RLRL_ 1
R_LLR 1
R_RLL 1
_LLRR 1
_LRLR 1
_RLLR 1
10
LLRR_ 3
LL_RR 1
LRLR_ 1
LRL_R 1
LRRL_ 1
LR_LR 1
RL...

output:

2368 1088 0 640 
3584 128 256 128 
512 3008 384 192 
1024 1024 1024 1024 
3456 256 256 128 
2048 1472 384 192 
4064 0 0 32 
2688 448 480 480 
4032 0 32 32 
1280 2240 384 192 
0 3968 0 128 
3408 352 168 168 
704 2240 768 384 
4095 0 0 1 
4064 0 0 32 
2048 0 1536 512 
3632 134 165 165 
4095 0 0 1 
864...

result:

ok 400 numbers

Test #16:

score: 5
Accepted
time: 41ms
memory: 34940kb

input:

16 100
23
LLRR_ 306
LLR_R 264
LL_RR 252
LRLR_ 23
LRL_R 176
LRRL_ 119
LRR_L 351
LR_LR 189
LR_RL 16
L_LRR 105
L_RLR 786
RLRL_ 390
RLR_L 81
RL_LR 403
RRL_L 345
RR_LL 381
R_LLR 66
R_LRL 112
R_RLL 164
_LLRR 38
_LRLR 115
_RLLR 90
_RLRL 228
8
LLRR_ 1367
LRLR_ 327
LRL_R 47
L_RLR 571
RLR_L 1069
R_RLL 611
_LL...

output:

17680556 3304561 202402848 633576084 
0 487458002 683875200 683875200 
301339126 658321087 29122532 866425657 
682988465 0 0 173975584 
0 79011881 623353314 154598854 
996507569 816670757 198383443 841890986 
625333936 813139915 465085349 949893555 
0 500720912 677243745 677243745 
138596030 1598968...

result:

ok 400 numbers

Test #17:

score: 5
Accepted
time: 84ms
memory: 36368kb

input:

17 100
18
LLRR_ 3108
LLR_R 3148
LRLR_ 2708
LRL_R 8648
LRRL_ 4617
LR_LR 8660
LR_RL 1216
L_LRR 7752
L_RLR 8022
RLRL_ 9170
RLR_L 2351
RRL_L 791
R_LLR 8061
R_LRL 2054
R_RLL 1127
_LLRR 10041
_LRLR 229
_RLRL 18297
18
LLR_R 8502
LL_RR 8872
LRLR_ 2991
LRR_L 5562
LR_LR 8388
LR_RL 2111
L_LRR 11234
RLRL_ 4073
...

output:

752224837 946662040 33722628 802140589 
58130126 697177505 277967707 503230403 
714800214 985152346 417365540 417431994 
292040797 644148641 945708069 652852587 
725096468 0 904826813 904826813 
700062037 914317224 959307593 959307593 
475115377 549213686 0 512176678 
200145646 554722456 494941356 2...

result:

ok 400 numbers

Test #18:

score: 5
Accepted
time: 126ms
memory: 37856kb

input:

18 100
23
LLRR_ 16285
LLR_R 7890
LL_RR 3986
LRLR_ 10856
LRL_R 6147
LRRL_ 9730
LRR_L 12509
LR_LR 11075
LR_RL 16759
L_LRR 1654
L_RLR 11265
RLRL_ 22225
RLR_L 4869
RL_LR 6561
RRL_L 3851
RR_LL 4129
R_LLR 10960
R_LRL 3163
R_RLL 16029
_LLRR 3332
_LRLR 2246
_RLLR 5355
_RLRL 9124
4
LL_RR 45823
LRRL_ 103101
L...

output:

722491944 995304472 102156400 968788971 
297290784 0 417454390 77507907 
0 792253080 0 1 
6930546 119718094 622924258 42680183 
889003663 937461334 867023241 95253549 
295918826 886988668 774252550 831581743 
70806754 906939031 415550585 397201064 
950201908 928795408 974922736 933066088 
0 99274504...

result:

ok 400 numbers

Test #19:

score: 5
Accepted
time: 484ms
memory: 50504kb

input:

19 100
23
LLRR_ 47450
LLR_R 33776
LL_RR 15472
LRLR_ 29835
LRL_R 19085
LRRL_ 53618
LRR_L 25656
LR_LR 38913
LR_RL 58698
L_LRR 64613
L_RLR 65782
RLRL_ 63900
RLR_L 64444
RL_LR 35115
RRL_L 82578
RR_LL 6705
R_LLR 79673
R_LRL 41936
R_RLL 10933
_LLRR 24642
_LRLR 60897
_RLLR 6400
_RLRL 69879
23
LLRR_ 49521
L...

output:

894742756 619903515 950564313 950795592 
478992016 770435371 576677595 591656841 
924757542 622868165 159318990 710817126 
816121154 261800132 599255795 740584742 
746857375 661124995 0 11535100 
462503812 677126450 964185841 313945720 
955101253 536332090 297028812 629299668 
683236993 871936240 15...

result:

ok 400 numbers

Test #20:

score: 5
Accepted
time: 480ms
memory: 50508kb

input:

20 100
11
LLRR_ 65785
LLR_R 141603
LRLR_ 4897
LRL_R 84299
LRR_L 46271
L_RLR 144517
RL_LR 105872
RRL_L 21634
RR_LL 49891
_RLLR 141609
_RLRL 193622
15
LL_RR 118203
LRLR_ 86748
LRR_L 107291
LR_LR 43541
LR_RL 50973
L_LRR 39982
L_RLR 24845
RLRL_ 94232
RRL_L 104857
RR_LL 67123
R_LLR 74924
R_LRL 3825
R_RLL...

output:

394116507 884396595 460458484 678790237 
33708150 368409811 517378074 500021435 
674766003 191397615 644641951 906956254 
147133476 732971372 212424823 326987799 
65716750 475890455 763033128 114877137 
0 0 709758735 709758735 
360370187 754566429 507321498 795503709 
247447503 632861954 11882597 52...

result:

ok 400 numbers

Extra Test:

score: 0
Extra Test Passed