QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#470939#6698. Flipping GamezzisjtuAC ✓87ms3972kbC++231.6kb2024-07-10 16:58:432024-07-10 16:58:43

Judging History

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

  • [2024-07-10 16:58:43]
  • 评测
  • 测评结果:AC
  • 用时:87ms
  • 内存:3972kb
  • [2024-07-10 16:58:43]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
#define lowbit(i) ((i)&(-i))
#define pii pair<int,int>
#define endl '\n'
#define mk(x,y) make_pair(x,y)
#define popcount(x) __builtin_popcount(x)
const double pi=3.14159265358979323846;
const double eps=1e-9;
const int inf=1e9;
const long long INF=4e18;
const int mod=998244353;
using namespace std;
const int N=110;
int qpow(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)ans=(long long)ans*a%mod;
        b>>=1;
        a=(long long)a*a%mod;
    }
    return ans;
}
int fact[N],infact[N];
void init()
{
    fact[0]=infact[0]=1;
    for(int i=1;i<N;i++)
    {
        fact[i]=(long long)fact[i-1]*i%mod;
        infact[i]=(long long)infact[i-1]*qpow(i,mod-2)%mod;
    }
}
int C(int a,int b)
{
    if(a<0||b<0||a<b) return 0;
    return (long long)fact[a]*infact[b]%mod*infact[a-b]%mod;// fact[a]:a!  infact[a]:1/(a!)
}
void solve()
{
	int n,m,k;
	cin>>n>>k>>m;
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<n;i++){
		cnt+=s[i]!=t[i];
	}
	vector<vector<ll>>dp(k+1,vector<ll>(n+1,0));
	dp[0][cnt]=1;
	for(int i=0;i<k;i++){
		for(int j=0;j<=n;j++){
			for(int x=0;x<=j&&x<=m;x++){
				if(n-j>=m-x)dp[i+1][j-x+m-x]=(dp[i+1][j-x+m-x]
					+1ll*dp[i][j]*C(j,x)%mod*C(n-j,m-x))%mod;
			}
		}
	}
	cout<<dp[k][0]<<endl;
	// cout<<C(5,3)<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    init();
    int T=1;
    cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

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

output:

2
1
7

result:

ok 3 number(s): "2 1 7"

Test #2:

score: 0
Accepted
time: 87ms
memory: 3972kb

input:

1000
8 50 2
11111001
01100001
13 4 5
0010011001101
0000001010010
15 58 12
011111110110100
011010000101000
15 30 2
000101100111101
100010100110000
16 99 15
0111011010111101
1000100101011100
7 73 1
0010010
1010111
1 45 1
1
1
15 64 4
111000001000100
111000110011011
13 16 6
0000001101000
0101001010111
5...

output:

0
0
0
0
0
565123576
0
671397628
866048220
0
0
0
934159397
0
0
0
657964873
0
0
0
297620792
518284447
16636231
1
294524820
259008109
0
0
0
0
0
0
990349196
899244686
0
0
497963164
0
49814547
0
0
0
0
0
529815127
411739397
562040211
0
0
0
0
0
0
0
531433326
0
77531359
703399699
0
0
0
1
0
896329183
0
0
0
0...

result:

ok 1000 numbers