QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#471136#6698. Flipping Gamemufeng12RE 0ms0kbC++232.2kb2024-07-10 18:30:562024-07-10 18:30:58

Judging History

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

  • [2024-07-10 18:30:58]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-10 18:30:56]
  • 提交

answer

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 0x3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define maxint INT32_MAX
#define minint INT32_MIN
#define maxll INT64_MAX
#define minll INT64_MIN
#define MOD  998244353
#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
#pragma GCC optimize(2)
void write(int x);
ll c[120][120];
char *p1,*p2,buf[100000];
int read();
ll ksm(ll a,ll b,ll mod);
void yhsj(){
    memset(c,0,sizeof(c));
    c[1][1]=1;
    for(int i=2;i<=120;i++){
        for(int j=1;i<=i;j++){
            c[i][j]=(c[i-1][j]+c[i-1][j-1])%MOD;
        }
    }
}
void solve(){
    int n,m,k;
    cin>>n>>k>>m;
    string s1,s2;
    cin>>s1>>s2;
    int sum=0;
    int dp[120][120];
    for(int i=0;i<n;i++){
        sum+=abs(s1[i]-s2[i]);
    }
    dp[0][sum]=1;
    for(int i=1;i<=k;i++){
        for(int j=0;j<=n;j++){
            for(int x=0;x<=j;x++){
                if(n-j<m-x) continue;
                dp[i][j-m-2*x]+=(dp[i-1][j]*c[j][x]%MOD*c[n-j][m-x]%MOD)%MOD;
                dp[i][j-m-2*x]%=MOD;
            }
        }
    }
    cout<<dp[k][0]<<endl;
}


int main() {
    int t=1;
    yhsj();
    cin>>t;
    while(t--) solve();
    return 0;
}



void write(int x)
{
    if(x<0)
        putchar('-'),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
    return;
}
int read()
{
    int x=0,f=1;
    char ch=nc();
    while(ch<48||ch>57)
    {
        if(ch=='-')
            f=-1;
        ch=nc();
    }
    while(ch>=48&&ch<=57)
        x=x*10+ch-48,ch=nc();
   	return x*f;
}
ll ksm(ll a,ll b,ll mod){
    ll ans=1;
    a%=mod;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3
3 2 1
001
100
3 1 2
001
100
3 3 2
001
100

output:


result: