QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55880#4612. 福若格斯CharlieVinnie40 340ms42692kbC++203.8kb2022-10-15 15:22:012022-10-15 15:22:02

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:22:02]
  • 评测
  • 测评结果:40
  • 用时:340ms
  • 内存:42692kb
  • [2022-10-15 15:22:01]
  • 提交

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};
    For(i,-n,n) 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,-n,n) 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: 46ms
memory: 34868kb

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: 47ms
memory: 34812kb

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: 36ms
memory: 34976kb

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: 38ms
memory: 34728kb

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: 0
Wrong Answer
time: 170ms
memory: 42564kb

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 
364389290 844669928 0 240437250 
0 0 0 131072 
0 462894643 0 1 
0 0 0 763410233 
0 123008607 119213915 242222522 
13686453 28124982 0 763671952 
0 0 0 886807583 
253936107 656797655 0 875269...

result:

wrong answer 33rd numbers differ - expected: '451252114', found: '364389290'

Test #6:

score: 0
Wrong Answer
time: 195ms
memory: 42692kb

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:

wrong answer 117th numbers differ - expected: '709758734', found: '909457974'

Test #7:

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

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: 295ms
memory: 34960kb

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: 0
Wrong Answer
time: 41ms
memory: 34976kb

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 858860455 0 367927966 
12768...

result:

wrong answer 38th numbers differ - expected: '386822154', found: '858860455'

Test #10:

score: 0
Wrong Answer
time: 319ms
memory: 37272kb

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 
830197923 501747966 0 369076126 
30513127 56246267 0 616018268 
575773749 821969784 0 303278482 
0 705279817 0 995742198 
916419189 722177065 0 62425761 
196296483 986317606 0 518407926 
0 0 0 702777662 
21156927 758526261 0 92133882...

result:

wrong answer 13th numbers differ - expected: '335337504', found: '830197923'

Test #11:

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

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: 0
Wrong Answer
time: 300ms
memory: 38784kb

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 
597106887 994200893 499703086 499703086 
918472178 721018091 974734018 974734018 
726434142 347015254 0 519020203 
49423178 298370202 123215933 123215933 
565446480 778951006 6...

result:

wrong answer 17th numbers differ - expected: '272500237', found: '597106887'

Test #13:

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

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: 0
Wrong Answer
time: 335ms
memory: 41656kb

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 
407361529 650460751 436281229 869595643 
914415286 842340519 778495152 826692548 
692584243 167236716 252816920 252816920 
0 0 183605223 183605223 
0 0 0 367210446 
986...

result:

wrong answer 17th numbers differ - expected: '613456471', found: '407361529'

Test #15:

score: 0
Wrong Answer
time: 37ms
memory: 34900kb

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:

wrong answer 285th numbers differ - expected: '4095', found: '4083'

Test #16:

score: 0
Wrong Answer
time: 37ms
memory: 35004kb

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 
787427565 547682422 951189560 567153208 
895489175 436551105 0 523168122 
0 79011881 623353314 154598854 
130066533 796071452 452769601 476300816 
110955929 614689238 14605595 116713287 
0 500720912 677243745 677243745 
940562486...

result:

wrong answer 9th numbers differ - expected: '301339126', found: '787427565'

Test #17:

score: 0
Wrong Answer
time: 68ms
memory: 35536kb

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 
48021850 967589925 482237702 38656264 
617667045 109319399 482428386 327090911 
292040797 644148641 945708069 652852587 
366243529 646620486 261820863 261820863 
730985029 747084561 528340252 528340252 
224166575 909426772 0 402912394 
102812720 971179380 9525...

result:

wrong answer 5th numbers differ - expected: '58130126', found: '48021850'

Test #18:

score: 0
Wrong Answer
time: 107ms
memory: 36216kb

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 
569857024 711367442 514811781 992705540 
0 792253080 0 1 
659118875 594083167 669264713 866275032 
357779956 604560879 913398447 913002505 
993866648 572676533 416145357 806053249 
514242894 961062908 156033060 159158572 
152171560 431419420 409048023 7978584...

result:

wrong answer 5th numbers differ - expected: '297290784', found: '569857024'

Test #19:

score: 0
Wrong Answer
time: 340ms
memory: 37464kb

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 
301852547 675041740 89994412 352628771 
847508803 351449809 697635826 521167385 
816121154 261800132 599255795 740584742 
183502530 129299165 0 108471422 
462503812 677126450 964185841 313945720 
238251504 142789656 639137273 399339037 
251772085 435744422 23...

result:

wrong answer 5th numbers differ - expected: '478992016', found: '301852547'

Test #20:

score: 0
Wrong Answer
time: 335ms
memory: 40016kb

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 
563730966 550463029 921753697 381814131 
458898658 960913758 168108737 829840670 
275485952 777338802 439092405 925844664 
559148480 744705407 814490718 299417218 
0 0 709758735 709758735 
778246314 626183105 850625399 162707005 
361944478 517327624 627216915...

result:

wrong answer 5th numbers differ - expected: '33708150', found: '563730966'