QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198442#670. K-th StringkjhhjkiWA 1ms5516kbC++201.1kb2023-10-03 13:55:392023-10-03 13:55:41

Judging History

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

  • [2023-10-03 13:55:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5516kb
  • [2023-10-03 13:55:39]
  • 提交

answer

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define MAXN 100005
#define For(i,a,b) for(int i = (a), endi = (b); i <= endi; ++i)
#define foR(i,a,b) for(int i = (a), endi = (b); i >= endi; --i)
using namespace std;
typedef long long _ll;
const _ll P = 1e9+7;

int n,m,k,len,cnt,sub,dp[27][27][602][2];
_ll ans;
char ch;
string s;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k >> s;
    ch = s[0]; m = ch-'a'; len = s.length();
    if((k -= len) <= 0) { cout << 0; return 0; }
    For(i,0,len-1)
        if(s[i] < ch)
            --m, sub += i, ++cnt;
    dp[0][0][0][0] = 1;
    For(i,1,n) For(j,0,m) For(k,0,((n+1)*n)>>1) 
    {
        For(t,0,1)
        {
            dp[i][j][k][t] = (dp[i][j][k][t]+dp[i-1][j][k][t]) %P;
            dp[i][j+1][k+n-i][t] = (dp[i][j+1][k+n-i][t]+dp[i-1][j][k][t]) %P;
            
        }
        if(i+len-1 <= n)
            dp[i+len-1][j][k+(n-i)*cnt-sub][1] = (dp[i+len-1][j][k+(n-i)*cnt-sub][1]+dp[i-1][j][k][0]);
    }
	ans=dp[n][m][k][1];
	For(i,1,m) ans = ans*i%P;
	For(i,1,n-m-len) ans = ans*i%P;
    cout << ans;
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5516kb

input:

7 12
caedgfb

output:

1

result:

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