QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#339641#7875. Queue Sorting275307894a#WA 23ms5184kbC++141.6kb2024-02-27 18:39:542024-02-27 18:39:55

Judging History

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

  • [2024-02-27 18:39:55]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:5184kb
  • [2024-02-27 18:39:54]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=500+5,M=N*10+5,K=1000+5,mod=998244353,Mod=+-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,A[N],m;
ll f[N],g[N],C[N][N];
void Solve(){
	int i,j,h;scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&A[i]),m+=A[i];
	for(i=0;i<=n;i++) for(C[i][0]=j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	f[0]=1;int sum=0;
	for(i=1;i<=n;i++) if(A[i]){
		Mc(g,f);Me(f,0);
		for(j=0;j<=m;j++) f[j]=g[j];
		for(int k=1;k<=A[i];k++){
			for(j=0;j<=m;j++) {	
				for(h=j+k;h<=sum+k;h++){
					f[h]=(f[h]+g[j]*C[h-j-1][k-1])%mod;
				}
			}
		}
		sum+=A[i];
	}
	printf("%lld\n",f[m]);
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

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

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 23ms
memory: 5184kb

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:

816381903

result:

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