QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#278311#7875. Queue SortinglifanCompile Error//C++141.2kb2023-12-07 14:46:262023-12-07 14:46:26

Judging History

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

  • [2023-12-07 14:46:26]
  • 评测
  • [2023-12-07 14:46:26]
  • 提交

answer

// 
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define op(x) ((x&1)?x+1:x-1)
#define odd(x) (x&1)
#define even(x) (!odd(x))
#define lc(x) (x<<1)
#define rc(x) (lc(x)|1)
#define lowbit(x) (x&-x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
using namespace std;
const int MAXN = 510,mod = 998244353;
void add(ll& x,ll y){x=(x+y)%mod;}
ll addv(ll x,ll y){return (x+y)%mod;}
//
ll n,a[MAXN],dp[MAXN][MAXN],s;
ll C[MAXN*2][MAXN*2];

int main(){
	rep(i,0,1000){
		C[i][0]=1;
		rep(j,1,i)C[i][j]=addv(C[i-1][j-1],C[i-1][j]);
	}

	cin>>n;
	rep(i,1,n)cin>>a[i];
	s=1;
	while(s<=n && !a[s])s++;
	if(s==n+1)return (cout<<"1\n"),0;

	ll sum=a[s];
	dp[s][0]=1; 
	rep(i,s+1,n){
		if(!a[i]){
			memcpy(dp[i],dp[i-1],sizeof dp[i]);
			continue;
		}
		rep(j,0,sum)if(dp[i-1][j]){
			ll val=dp[i-1][j];
			add(dp[i][j],val);
			rep(k,0,a[i]-1){ //枚举最后一格放的个数	
				ll r=a[i]-k;
				rep(p,j,sum-1){
					ll x=p-j+1,w=C[x+r-2][r-1];
					add(dp[i][p+r],val*w);
				}
			}
		}
		sum+=a[i];
	}

	ll ans=0;
	rep(i,0,sum)add(ans,dp[n][i]);
	cout<<ans+1<<endl;

    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:28:9: error: ‘cin’ was not declared in this scope
   28 |         cin>>n;
      |         ^~~
answer.code:1:1: note: ‘std::cin’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
  +++ |+#include <iostream>
    1 | //
answer.code:32:27: error: ‘cout’ was not declared in this scope
   32 |         if(s==n+1)return (cout<<"1\n"),0;
      |                           ^~~~
answer.code:32:27: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code:38:25: error: ‘memcpy’ was not declared in this scope
   38 |                         memcpy(dp[i],dp[i-1],sizeof dp[i]);
      |                         ^~~~~~
answer.code:1:1: note: ‘memcpy’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
  +++ |+#include <cstring>
    1 | //
answer.code:57:9: error: ‘cout’ was not declared in this scope
   57 |         cout<<ans+1<<endl;
      |         ^~~~
answer.code:57:9: note: ‘std::cout’ is defined in header ‘<iostream>’; did you forget to ‘#include <iostream>’?
answer.code:57:22: error: ‘endl’ was not declared in this scope
   57 |         cout<<ans+1<<endl;
      |                      ^~~~
answer.code:1:1: note: ‘std::endl’ is defined in header ‘<ostream>’; did you forget to ‘#include <ostream>’?
  +++ |+#include <ostream>
    1 | //