QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198452#670. K-th StringkjhhjkiWA 1ms3592kbC++201.1kb2023-10-03 13:59:002023-10-03 13:59:01

Judging History

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

  • [2023-10-03 13:59:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3592kb
  • [2023-10-03 13:59:00]
  • 提交

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+1)*cnt-sub][1] = (dp[i+len-1][j][k+(n-i+1)*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: 100
Accepted
time: 1ms
memory: 3488kb

input:

7 12
caedgfb

output:

0

result:

ok single line: '0'

Test #2:

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

input:

2 3
b

output:

0

result:

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