QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#274940#7875. Queue SortingWilliamHuWA 272ms6476kbC++201.1kb2023-12-04 08:21:022023-12-04 08:21:02

Judging History

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

  • [2023-12-04 08:21:02]
  • 评测
  • 测评结果:WA
  • 用时:272ms
  • 内存:6476kb
  • [2023-12-04 08:21:02]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m, a[1010], f[510][510], cnt = 1;
int mod = 998244353, c[510][510];
signed main() {
	cin>>n;
	for(int i = 1;i <= n;i ++)
	{
		cin>>a[cnt];
		m += a[cnt];
		if(a[cnt])cnt ++;
	}
	c[0][0] = 1;
	for(int i = 1;i <= m;i ++)
	{
		c[i][0] = 1;
		for(int j = 1;j <= i;j ++)
		{
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
			//cout<<i<<' '<<j<<' '<<c[i][j]<<endl;
		}
	}
	cnt -= 1;
	f[1][0] = 1;
	int tot = 0;
	//for(int i = 1;i <= cnt;i ++)cout<<a[i]<<' ';
	for(int i = 1;i < cnt;i ++)
	{
		f[i][0] = 1;
		tot += a[i];
		for(int j = 0;j <= m;j ++)
		{
			for(int k = 0;k <= tot;k ++)
			{
				for(int x = 0;x < a[i + 1];x ++)
				{
					int w = a[i + 1] - x - 1;
					if(j - k - 1 + w < 0 and j != 0)continue;
					f[i + 1][x + k + 1] = (f[i + 1][x + k + 1] + f[i][j] * c[max(0ll, j - k - 1 + w)][w] % mod) % mod;
					//cout<<i<<' '<<j<<' '<<x+j+1<<' '<<w<<f[i +1][x + k +1]<<endl;
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0;i <= m;i ++)ans += f[cnt][i];
	cout<<ans;
	return 0;
} 


詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5616kb

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 272ms
memory: 6476kb

input:

300
0 5 2 2 1 0 3 2 2 5 2 1 1 2 1 3 2 3 2 0 0 0 0 1 2 2 3 0 2 2 3 2 0 2 3 0 6 0 0 2 0 1 3 2 1 1 1 3 4 0 1 0 4 1 1 1 1 1 1 2 3 2 1 2 3 2 3 0 5 3 3 2 0 1 1 0 2 1 1 2 0 0 2 1 1 3 2 2 1 2 1 3 0 3 0 1 2 2 0 5 0 2 2 0 0 0 1 2 1 4 2 1 1 0 3 0 2 0 3 1 1 2 0 2 1 1 0 2 0 1 2 2 3 3 1 1 1 1 0 1 3 3 1 0 2 2 4 2 ...

output:

236951986462

result:

wrong answer 1st numbers differ - expected: '507010274', found: '236951986462'