QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198997#670. K-th Stringpengpeng_fudanWA 1ms5488kbC++141.0kb2023-10-03 20:10:352023-10-03 20:10:36

Judging History

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

  • [2023-10-03 20:10:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5488kb
  • [2023-10-03 20:10:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ll=long long;
const ll mod=1e9+7;
int n,z;
string s;
int sz;
ll ans=0;
ll dp[30][30][1010];
ll d[30][1010];
void solve(int x) {
    for(int i=0;i<=n;i++)   for(int j=0;j<=sz;j++)  for(int k=0;k<=z;k++)   dp[i][j][k]=0;
    int ni=sz-1;
    int lw=s[1]-'a';
    for(int i=2;i<=sz;i++){
        if(s[i]<s[1]){
            ni+=n-(x+i-1)+1;
            lw--;
        }
    }
    dp[0][0][0]=1;
    for(int i=1;i<=n-sz;i++){
        for(int j=0;j<=lw;j++){
            for(int k=0;k<=z-ni;k++){
                dp[i][j][k]=dp[i-1][j][k];
                int ad=(i<x?n-i+1:n-(i+sz)+1);
                if(j>=1&&k>=ad)    dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-1][k-ad])%mod;
            }
        }
    }
    for(int i=0;i<=lw;i++)  ans=(ans+dp[n-sz][i][z-ni])%mod;
}
int main() {
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>n>>z>>s;
    s=' '+s;
    sz=s.size()-1;
    for(int i=1;i<=n-sz+1;i++)  solve(i);
    cout<<ans<<'\n';
    return 0;
}

詳細信息

Test #1:

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

input:

7 12
caedgfb

output:

0

result:

ok single line: '0'

Test #2:

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

input:

2 3
b

output:

0

result:

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