QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#417502#8717. 骰子grass8cow#WA 590ms28052kbC++171.6kb2024-05-22 19:20:262024-05-22 19:20:27

Judging History

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

  • [2024-05-22 19:20:27]
  • 评测
  • 测评结果:WA
  • 用时:590ms
  • 内存:28052kb
  • [2024-05-22 19:20:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int p[1510][210],n,m,q,an[1510][1510],b[210],f[210];
int a[1510][210],t[1510][210];
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int L[601000],R[600100],ans[601000];
void cdq(int l,int r,vector<int>qb){
    if(l==r){
        int an=0;
        for(int i=0;i<=m;i++)
            ad(an,1ll*p[l][i]*b[i]%mod);
        for(int x:qb)ans[x]=an;
        return;
    }
    int mi=(l+r)>>1;
    vector<int>ql,qr,mt;
    for(int x:qb){
        if(R[x]<=mi)ql.pb(x);
        else if(L[x]>mi)qr.pb(x);
        else mt.pb(x);
    }
    for(int i=0;i<=m;i++)a[mi+1][i]=b[i];
    t[mi][0]=1;
    for(int i=mi;i>=l;i--){
        for(int j=0;j<=m;j++){
            __int128 su=0;
            for(int k=j;k<=m;k++)su+=1ll*a[i+1][k]*p[i][k-j];
            a[i][j]=su%mod;
        }
    }
    for(int i=mi+1;i<=r;i++){
        for(int j=0;j<=m;j++){
            __int128 su=0;
            for(int k=0;k<=j;k++)su+=1ll*t[i-1][k]*p[i][j-k];
            t[i][j]=su%mod;
        }
    }
    for(int o:mt){
        for(int i=0;i<=m;i++)
            ad(ans[o],1ll*t[R[o]][i]*a[L[o]][i]%mod);
    }
    cdq(l,mi,ql),cdq(mi+1,r,qr);
}
int main(){
    scanf("%d%d%d",&n,&m,&q);
    for(int i=0;i<=m;i++)scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)for(int j=0;j<=m;j++){
        scanf("%d",&p[i][j]);
        if(p[i][j]>=mod)p[i][j]-=mod;
    }
    vector<int>al;
    for(int i=1;i<=q;i++)scanf("%d%d",&L[i],&R[i]),al.pb(i);
    cdq(1,n,al);
    for(int i=1;i<=q;i++)printf("%d\n",ans[i]);
    return 0;
}

詳細信息

Test #1:

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

input:

3 3 3
4 3 2 1
0 1 0 1000000007
0 500000004 0 500000004
0 0 500000004 500000004
1 1
1 2
1 3

output:

3
1
0

result:

ok 3 number(s): "3 1 0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 16120kb

input:

3 3 6
4 3 2 1
1000000007 0 1 0
1000000007 1 0 0
1000000007 0 1 0
1 1
1 2
1 3
2 2
2 3
3 3

output:

2
1
0
3
1
2

result:

ok 6 numbers

Test #3:

score: 0
Accepted
time: 2ms
memory: 12308kb

input:

1 1 1
604063100 57375033
742299910 257700098
1 1

output:

148903503

result:

ok 1 number(s): "148903503"

Test #4:

score: -100
Wrong Answer
time: 590ms
memory: 28052kb

input:

1500 200 600000
253665324 876103781 804024983 929290295 908790466 176299158 528078340 696679927 416465140 509641654 705083449 361711737 250659645 735832780 35321360 383752049 203979021 178832532 785212637 514502839 169840231 65809146 504755349 516829442 382478309 901925498 142312128 782336477 741339...

output:

66394849
858043015
353822347
207970046
751313065
544692508
699743627
390858705
334940115
441003348
589429674
891250455
147055038
949270774
782296292
811515252
608076278
772991067
609961969
3444634
534397763
960286396
508610642
605601387
259265811
618584891
662015873
465616975
355211926
398786302
748...

result:

wrong answer 3rd numbers differ - expected: '290088512', found: '353822347'