QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#749782#9536. Athlete Welcome CeremonyForever_Young#WA 1ms6152kbC++231.3kb2024-11-15 10:12:272024-11-15 10:12:28

Judging History

This is the latest submission verdict.

  • [2024-11-15 10:12:28]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 6152kb
  • [2024-11-15 10:12:27]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define data dataa
using LL=long long;
using ULL=unsigned long long;
using LD=long double;
const int MOD=int(1e9)+7;
int dp[310][3][310][310],ans[310][310][310],n,q;
char s[310];
void update(int&x,int y){x=(x+y)%MOD;}
int main()
{
    scanf("%d%d",&n,&q);
    scanf("%s",s+1);
    int cnt=0;
    rep(i,n)cnt+=s[i]=='?';
    for(int i=0;i<3;i++)if(s[1]=='?'||s[1]==i+'a')dp[1][i][s[1]=='?'&&i==0][s[1]=='?'&&i==1]=1;
    rep(i,n-1)
    for(int j=0;j<3;j++)
    for(int k=0;k<3;k++)
    if(k!=j)
    {
        if(s[i+1]!='?'&&s[i+1]!=k+'a')continue;
        int dx=s[i+1]=='?'&&k==0,dy=s[i+1]=='?'&&k==1;
        for(int x=0;x<=i;x++)for(int y=0;y<=i;y++)update(dp[i+1][k][x+dx][y+dy],dp[i][j][x][y]);
    }
    for(int i=0;i<3;i++)for(int x=0;x<=cnt;x++)for(int y=0;y<=cnt-x;y++){int z=cnt-x-y;update(ans[x][y][z],dp[n][i][x][y]);}
    rep(i,3)
    for(int x=i==1;x<=cnt;x++)
    for(int y=i==2;y<=cnt;y++)
    for(int z=i==2;z<=cnt;z++)
    update(ans[x][y][z],ans[x-(i==1)][y-(i==2)][z-(i==3)]);
    rep(i,q)
    {
        int x,y,z;scanf("%d%d%d",&x,&y,&z);
        x=min(x,cnt);y=min(y,cnt);z=min(z,cnt);
        printf("%d\n",ans[x][y][z]);
    }
    return 0;
}

詳細信息

Test #1:

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

input:

6 3
a?b??c
2 2 2
1 1 1
1 0 2

output:

3
1
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 6152kb

input:

6 3
??????
2 2 2
2 3 3
3 3 3

output:

30
72
96

result:

ok 3 lines

Test #3:

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

input:

1 1
?
0 1 1

output:

2

result:

ok single line: '2'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 5996kb

input:

10 10
acab?cbaca
0 2 0
1 1 2
4 2 3
1 1 1
3 5 1
0 5 2
2 2 0
1 2 5
4 3 0
1 1 3

output:

0
0
0
0
0
0
0
0
0
0

result:

wrong answer 2nd lines differ - expected: '1', found: '0'