QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275192#7875. Queue Sortingucup-team902#WA 28ms6360kbC++202.7kb2023-12-04 14:52:422023-12-04 14:52:42

Judging History

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

  • [2023-12-04 14:52:42]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:6360kb
  • [2023-12-04 14:52:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
namespace IO{

#define gc getchar
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}

}
using IO::read;
using IO::readll;
using IO::readchar;
using IO::readstring;
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}
cs int mod=998244353;
inline int add(int a,int b){return (a+b)>=mod?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){static ll r;r=(ll)a*b;return (r>=mod)?(r%mod):r;}
inline void Add(int &a,int b){a=(a+b)>=mod?(a+b-mod):(a+b);}
inline void Dec(int &a,int b){a=(a<b)?(a-b+mod):(a-b);}
inline void Mul(int &a,int b){static ll r;r=(ll)a*b;a=(r>=mod)?(r%mod):r;}
inline int ksm(int a,int b,int res=1){for(;b;b>>=1,Mul(a,a))(b&1)&&(Mul(res,a),1);return res;}
inline int Inv(int x){return ksm(x,mod-2);}
inline int fix(ll x){x%=mod;return (x<0)?x+mod:x;}
cs int N=505;
int f[N][N];
int a[N],c[N][N],n;
int s[N][N];
int calc(int x,int y,int l){
	int l1=max(0,y-x),r1=min(l,y);
	int xx=s[l][r1];
	if(l1>r1)return 0;
	if(l1)xx=dec(xx,s[l][l1-1]);
	return xx;
}
void solve(){
	for(int i=0;i<N;i++){
		c[i][i]=c[i][0]=1;
		for(int j=1;j<i;j++)c[i][j]=add(c[i-1][j],c[i-1][j-1]);
		s[i][0]=c[i][0];
		for(int j=1;j<i;j++)s[i][j]=add(s[i][j-1],c[i][j]);
	}
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	int s=0;
	for(int i=1;i<=n;i++){
		if(a[i]){
			if(s==0){
				f[i][0]=1;
				s+=a[i];
			}
			else{
				for(int j=0;j<=s;j++){
					Add(f[i][j],f[i-1][j]);
					for(int k=j+a[i];k<=s+a[i];k++){
						Add(f[i][k],mul(f[i-1][j],calc(min(a[i]-1,s+a[i]-k-1),a[i]-1,k-j-1)));
					}
				}
				s+=a[i];
			}
		}
		else{
			memcpy(f[i],f[i-1],sizeof(f[i]));;
		}
	}
	int res=0;
	for(int i=0;i<=s;i++)Add(res,f[n][i]);
	cout<<res<<'\n';
}
int main(){ 
	#ifdef Stargazer
	freopen("1.in","r",stdin);
	#endif
	int T=1;
	while(T--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 1 1 1

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: -100
Wrong Answer
time: 28ms
memory: 6300kb

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:

75354768

result:

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