QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722119#9536. Athlete Welcome Ceremonythe_foo#WA 1ms8056kbC++202.2kb2024-11-07 17:54:182024-11-07 17:54:19

Judging History

This is the latest submission verdict.

  • [2024-11-07 17:54:19]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 8056kb
  • [2024-11-07 17:54:18]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
using LL = long long;
using ll = long long;
const int mod=1e9+7;
int n,q,a[302];
string s;
int f[302][302][302][3],all,g[302][302][302];
void solve() {

    cin>>n>>q>>s;
    int cnt=0;
    for(int i=0;i<s.size();i++) {

        if(s[i]=='?')a[i+1]=3,all++;
        else a[i+1]=s[i]-'a';
    }
    for(int c=0;c<=2;c++) {
        if(a[1]==0){
            f[1][0][0][0]=1;
        }
        if(a[1]==1) {
            f[1][0][0][1]=1;
        }
        if(a[1]==2) {
            f[1][0][0][2]=1;
        }
        if(a[1]==3) {
            f[1][1][0][0]=1;
            f[1][0][1][1]=1;
            f[1][0][0][2]=1;
        }
    }
    for(int i=2;i<=n;i++) {
        for(int j=0;j<=n;j++)
            for(int k=0;k<=n;k++) {
                for(int l=0;l<=2;l++)if(a[i]!=l){
                    if(a[i]<=2)f[i][j][k][a[i]]=(f[i][j][k][a[i]]+f[i-1][j][k][l])%mod;
                    else {
                        for(int c=0;c<=2;c++)if(c!=l) {
                            if(c==0&&j)f[i][j][k][c]=(f[i-1][j-1][k][l]+f[i][j][k][c])%mod;
                            if(c==1&&k) f[i][j][k][c]=(f[i-1][j][k-1][l]+f[i][j][k][c])%mod;
                            if(c==2) f[i][j][k][c]=(f[i-1][j][k][l]+f[i][j][k][c])%mod;
                        }
                    }
                }

            }
    }

        for(int j=0;j<=n;j++)
            for(int k=0;k<=n;k++)
                for(int l=0;l<=2;l++) {
                    int c=all-j-k;

                    g[j+1][k+1][c+1]=(f[n][j][k][l]+g[j+1][k+1][c+1])%mod;
                }
    for(int a=1;a<=n;a++){
        for(int b=1;b<=n;b++)
            for(int c=1;c<=n;c++) {
                g[a][b][c]=(mod*3+g[a][b][c]+g[a-1][b][c]+g[a][b-1][c]+g[a][b][c-1]-g[a-1][b-1][c]-g[a-1][b][c-1]-g[a][b-1][c-1]+g[a-1][b-1][c-1])%mod;
            }
    }
    int x,y,z;
    for(int i=1;i<=q;i++) {
        cin>>x>>y>>z;
        cout<<g[x+1][y+1][z+1]<<endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}
/*
6 3
??????
2 2 2
2 3 3
3 3 3
 */

詳細信息

Test #1:

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

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: 8012kb

input:

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

output:

30
72
96

result:

ok 3 lines

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 7728kb

input:

1 1
?
0 1 1

output:

0

result:

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