QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#592896#6698. Flipping GamePonyHexCompile Error//C++208.4kb2024-09-27 09:40:162024-09-27 09:40:17

Judging History

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

  • [2024-09-27 09:40:17]
  • 评测
  • [2024-09-27 09:40:16]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define ll long long
//#define double long double
#define lc u<<1
#define rc u<<1|1
#define X first
#define Y second
#define endl "\n"
#define int long long
const int N = 2e5 + 50;
const int M = 5e5 + 5;
const ll maxm = 1e18 + 5;
const ll mod = 998244353;
int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
//random_shuffle(id + 1, id + n + 1);
ll ksm(ll a, ll b);
ll gcd(ll a, ll b);

template<class T>inline void read(T& x) {
	x = 0;
	char c = getchar();
	while (!isdigit(c))c = getchar();
	while (isdigit(c))x = x * 10 + (c & 15), c = getchar();
}

void write(ll x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
	return;
}

ll len, k, m;
string str, demo;
ll dp[105][105];
ll f[105];
ll inv[105];


ll C(ll base, ll u) {
	if (u == base || u == 0ll)return 1;
	//cout << u << " " << base << endl;
	//cout << f[base] << " " << inv[base - u] << " " << inv[u] << endl;
	ll ans = 1; ans = (f[base] * inv[base - u]) % mod * inv[u] % mod;
	return ans % mod;
}

void solve()
{
	//我感觉是组合数学,但是我又不知道怎么搞出来
	//首先有必须操作的元素,在进行必要的操作后,剩余的操作已经是任选元素,操作偶数次,只要合法(在同一次操作没有两个相同元素)
	//是否可以使用总情况减出来?,总情况的话,应为Cn,m*k,这样就是所有的情况,不合法,就是对给出的任意需要操作奇次的元素,操作偶次
	//但是这样的情况数依然非常多
	//dp?好多dP的题我看不出来是dp,
	//感觉自己想想不出来,看了题解思路才有感觉,要想正确的转移到最终状态,最终状态的特质有0,1的个数,但是不对,因为还有位置
	//如果数据较小我就用状压来储存状态了,但是100开不出来,所以状态的设置不能携带0,1,的具体位置
	//那么状态就不应该是0,1的个数,然后题解使用了一种状态,在第k轮与最终状态对应位置元素不同的个数
	//这样就很对了,每次选择相同的元素修改,不同的元素修改,和为m,枚举情况即可
	//感觉一般组合数学会经常和dp连接起来,或者dfs,

	//忘取mod,嘶,t了,C得预处理出来


	cin >> len >> k >> m;
	cin >> str >> demo;
	for (int i = 0; i <= k; i++) {//开始设置初始状态
		for (int j = 0; j <= len; j++) {
			dp[i][j] = 0;
		}
	}
	//memset(dp, 0, sizeof(dp));
	//在第0轮,不同的元素个数直接统计即可
	ll num = 0;
	for (int i = 0; i < len; i++) {
		if (str[i] != demo[i])num++;
	}
	dp[0][num] = 1;
	/*
	for (int i = 1; i <= k; i++) {//枚举轮次
		for (int fj = 0; fj <= len; fj++) {//枚举过去的状态,不同元素的个数
			for (int j = 0; j + fj <= len; j++) {//枚举要得到的不同元素的个数
				ll val = m - j;//要修改的相同元素的个数
				if (val < 0)continue;
				if (len - fj < j)continue;
				if (fj < val)continue;
				//cout << i << " " << fj + j - val << " " << i - 1 << " " << fj << endl;
				//cout << dp[i - 1][fj] * C(len - fj, j) * C(fj, val) << endl;
				dp[i][fj + j - val] += ((dp[i - 1][fj] * C(len - fj, j)) % mod) * C(fj, val)%mod;
				dp[i][fj + j - val] % mod;
			}
		}
	}*/
	for (int i = 0; i <= k - 1; i++) {
		for (int j = 0; j <= len; j++) {
			for (int k = 0; k <= m; k++) {
				if (j >= k && len - j >= m - k) {
					dp[i + 1][j - k + m - k] += dp[i][j] * C(j,k) % mod * C(len-j,m-k) % mod;
					dp[i + 1][j - k + m - k] %= mod;
				}
			}
		}
	}
	cout<<dp[k][0]%mod<<endl;
	return;
}


signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	f[0] = 1;
	for (int i = 1; i <= 100; i++) {
		f[i] = i*f[i - 1]; f[i] %= mod;
		inv[i] = ksm(f[i], mod - 2);
	}
	int T = 1;
	cin >> T;
	//read(T);
	while (T--)
		solve();
	return 0;
}

/*PonyHex*/


ll ksm(ll a, ll b) {
	ll base = a;
	ll ans = 1;
	while (b) {
		if (b & 1)ans *= base % mod;
		ans %= mod;
		base *= base; base %= mod;
		b >>= 1;
	}
	return ans % mod;
}
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define ll long long
//#define double long double
#define lc u<<1
#define rc u<<1|1
#define X first
#define Y second
#define endl "\n"
#define int long long
const int N = 2e5 + 50;
const int M = 5e5 + 5;
const ll maxm = 1e18 + 5;
const ll mod = 998244353;
int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
//random_shuffle(id + 1, id + n + 1);
ll ksm(ll a, ll b);
ll gcd(ll a, ll b);

template<class T>inline void read(T& x) {
	x = 0;
	char c = getchar();
	while (!isdigit(c))c = getchar();
	while (isdigit(c))x = x * 10 + (c & 15), c = getchar();
}

void write(ll x)
{
	if (x < 0)
		putchar('-'), x = -x;
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
	return;
}

ll len, k, m;
string str, demo;
ll dp[105][105];
ll f[105];
ll inv[105];


ll C(ll base, ll u) {
	if (u == base || u == 0ll)return 1;
	//cout << u << " " << base << endl;
	//cout << f[base] << " " << inv[base - u] << " " << inv[u] << endl;
	ll ans = 1; ans = (f[base] * inv[base - u]) % mod * inv[u] % mod;
	return ans % mod;
}

void solve()
{
	//我感觉是组合数学,但是我又不知道怎么搞出来
	//首先有必须操作的元素,在进行必要的操作后,剩余的操作已经是任选元素,操作偶数次,只要合法(在同一次操作没有两个相同元素)
	//是否可以使用总情况减出来?,总情况的话,应为Cn,m*k,这样就是所有的情况,不合法,就是对给出的任意需要操作奇次的元素,操作偶次
	//但是这样的情况数依然非常多
	//dp?好多dP的题我看不出来是dp,
	//感觉自己想想不出来,看了题解思路才有感觉,要想正确的转移到最终状态,最终状态的特质有0,1的个数,但是不对,因为还有位置
	//如果数据较小我就用状压来储存状态了,但是100开不出来,所以状态的设置不能携带0,1,的具体位置
	//那么状态就不应该是0,1的个数,然后题解使用了一种状态,在第k轮与最终状态对应位置元素不同的个数
	//这样就很对了,每次选择相同的元素修改,不同的元素修改,和为m,枚举情况即可
	//感觉一般组合数学会经常和dp连接起来,或者dfs,

	//忘取mod,嘶,t了,C得预处理出来


	cin >> len >> k >> m;
	cin >> str >> demo;
	for (int i = 0; i <= k; i++) {//开始设置初始状态
		for (int j = 0; j <= len; j++) {
			dp[i][j] = 0;
		}
	}
	//memset(dp, 0, sizeof(dp));
	//在第0轮,不同的元素个数直接统计即可
	ll num = 0;
	for (int i = 0; i < len; i++) {
		if (str[i] != demo[i])num++;
	}
	dp[0][num] = 1;
	/*
	for (int i = 1; i <= k; i++) {//枚举轮次
		for (int fj = 0; fj <= len; fj++) {//枚举过去的状态,不同元素的个数
			for (int j = 0; j + fj <= len; j++) {//枚举要得到的不同元素的个数
				ll val = m - j;//要修改的相同元素的个数
				if (val < 0)continue;
				if (len - fj < j)continue;
				if (fj < val)continue;
				//cout << i << " " << fj + j - val << " " << i - 1 << " " << fj << endl;
				//cout << dp[i - 1][fj] * C(len - fj, j) * C(fj, val) << endl;
				dp[i][fj + j - val] += ((dp[i - 1][fj] * C(len - fj, j)) % mod) * C(fj, val)%mod;
				dp[i][fj + j - val] % mod;
			}
		}
	}*/
	for (int i = 0; i <= k - 1; i++) {
		for (int j = 0; j <= len; j++) {
			for (int k = 0; k <= m; k++) {
				if (j >= k && len - j >= m - k) {
					dp[i + 1][j - k + m - k] += dp[i][j] * C(j,k) % mod * C(len-j,m-k) % mod;
					dp[i + 1][j - k + m - k] %= mod;
				}
			}
		}
	}
	cout<<dp[k][0]%mod<<endl;
	return;
}


signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	f[0] = 1;
	for (int i = 1; i <= 100; i++) {
		f[i] = i*f[i - 1]; f[i] %= mod;
		inv[i] = ksm(f[i], mod - 2);
	}
	int T = 1;
	cin >> T;
	//read(T);
	while (T--)
		solve();
	return 0;
}

/*PonyHex*/


ll ksm(ll a, ll b) {
	ll base = a;
	ll ans = 1;
	while (b) {
		if (b & 1)ans *= base % mod;
		ans %= mod;
		base *= base; base %= mod;
		b >>= 1;
	}
	return ans % mod;
}
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

詳細信息

answer.code:149:2: error: stray ‘#’ in program
  149 | }#define _CRT_SECURE_NO_WARNINGS 1
      |  ^
answer.code:149:3: error: ‘define’ does not name a type
  149 | }#define _CRT_SECURE_NO_WARNINGS 1
      |   ^~~~~~
answer.code:162:11: error: redefinition of ‘const long long int N’
  162 | const int N = 2e5 + 50;
      |           ^
answer.code:14:11: note: ‘const long long int N’ previously defined here
   14 | const int N = 2e5 + 50;
      |           ^
answer.code:163:11: error: redefinition of ‘const long long int M’
  163 | const int M = 5e5 + 5;
      |           ^
answer.code:15:11: note: ‘const long long int M’ previously defined here
   15 | const int M = 5e5 + 5;
      |           ^
answer.code:164:10: error: redefinition of ‘const long long int maxm’
  164 | const ll maxm = 1e18 + 5;
      |          ^~~~
answer.code:16:10: note: ‘const long long int maxm’ previously defined here
   16 | const ll maxm = 1e18 + 5;
      |          ^~~~
answer.code:165:10: error: redefinition of ‘const long long int mod’
  165 | const ll mod = 998244353;
      |          ^~~
answer.code:17:10: note: ‘const long long int mod’ previously defined here
   17 | const ll mod = 998244353;
      |          ^~~
answer.code:166:5: error: redefinition of ‘long long int dx []’
  166 | int dx[] = { -1,0,1,0 };
      |     ^~
answer.code:18:5: note: ‘long long int dx [4]’ previously defined here
   18 | int dx[] = { -1,0,1,0 };
      |     ^~
answer.code:167:5: error: redefinition of ‘long long int dy []’
  167 | int dy[] = { 0,1,0,-1 };
      |     ^~
answer.code:19:5: note: ‘long long int dy [4]’ previously defined here
   19 | int dy[] = { 0,1,0,-1 };
      |     ^~
answer.code:172:30: error: redefinition of ‘template<class T> void read(T&)’
  172 | template<class T>inline void read(T& x) {
      |                              ^~~~
answer.code:24:30: note: ‘template<class T> void read(T&)’ previously declared here
   24 | template<class T>inline void read(T& x) {
      |                              ^~~~
answer.code:179:6: error: redefinition of ‘void write(long long int)’
  179 | void write(ll x)
      |      ^~~~~
answer.code:31:6: note: ‘void write(long long int)’ previously defined here
   31 | void write(ll x)
      |      ^~~~~
answer.code:189:4: error: redefinition of ‘long long int len’
  189 | ll len, k, m;
      |    ^~~
answer.code:41:4: note: ‘long long int len’ previously declared here
   41 | ll len, k, m;
      |    ^~~
answer.code:189:9: error: redefinition of ‘long long int k’
  189 | ll len, k, m;
      |         ^
answer.code:41:9: note: ‘long long int k’ previously declared here
   41 | ll len, k, m;
      |         ^
answer.code:189:12: error: redefinition of ‘long long int m’
  189 | ll len, k, m;
      |            ^
answer.code:41:12: note: ‘long long int m’ previously declared here
   41 | ll len, k, m;
      |            ^
answer.code:190:8: error: redefinition of ‘std::string str’
  190 | string str, demo;
      |        ^~~
answer.code:42:8: note: ‘std::string str’ previously defined here
   42 | string str, demo;
      |        ^~~
answer.code:190:13: error: redefinition of ‘std::string demo’
  190 | string str, demo;
      |             ^~~~
answer.code:42:13: note: ‘std::string demo’ previously defined here
   42 | string str, demo;
      |             ^~~~
answer.code:191:4: error: redefinition of ‘long long int dp [105][105]’
  191 | ll dp[105][105];
      |    ^~
answer.code:43:4: note: ‘long long int dp [105][105]’ previously declared here
   43 | ll dp[105][105];
      |    ^~
answer.code:192:4: error: redefinition of ‘long long int f [105]’
  192 | ll f[105];
      |    ^
answer.code:44:4: note: ‘long long int f [105]’ previously declared here
   44 | ll f[105];
      |    ^
answer.code:193:4: error: redefinition of ‘long long int inv [105]’
  193 | ll inv[105];
      |    ^~~
answer.code:45:4: note: ‘long long int inv [105]’ previously declared here
   45 | ll inv[105];
      |    ^~~
answer.code:196:4: error: redefinition of ‘long long int C(long long int, long long int)’
  196 | ll C(ll base, ll u) {
      |    ^
answer.code:48:4: note: ‘long long int C(long long int, long long int)’ previously defined here
   48 | ll C(ll base, ll u) {
      |    ^
answer.code:204:6: error: redefinition of ‘void solve()’
  204 | void solve()
      |      ^~~~~
answer.code:56:6: note: ‘void solve()’ previously defined here
   56 | void solve()
      |      ^~~~~
answer.code:264:8: error: redefinition of ‘int main()’
  264 | signed main()
      |        ^~~~
answer.code:116:8: note: ‘int main()’ previously defined here
  116 | signed main()
      |        ^~~~
answer.code:284:4: error: redefinition of ‘long long int ksm(long long int, long long int)’
  284 | ll ksm(ll a, ll b) {
      |    ^~~
answer.code:136:4: note: ‘long long int ksm(long long int, long long int)’ previously defined here
  136 | ll ksm(ll a, ll b) {
      |    ^~~
answer.code:295:4: error: redefinition of ‘long long int gcd(long long...