QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#153717#6408. Classical Counting ProblemqzezCompile Error//C++141.7kb2023-08-30 19:39:352023-08-30 19:39:35

Judging History

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

  • [2023-08-30 19:39:35]
  • 评测
  • [2023-08-30 19:39:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=2e2+10,V=4e4,M=V+10,mod=1e9+7;
int T,n,m,v,mx,a[N];
int cnt[N];
void reduce(int &x){
	x>=mod&&(x-=mod);
}
void Reduce(int &x){
	x<0&&(x+=mod);
}
int C[N][N];
void init(int n=200){
	for(int i=0;i<=n;i++)for(int j=C[i][0]=1;j<=i;j++){
		C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int i=0;i<=n;i++)for(int j=i;j>=0;j--){
		C[i][j]=(C[i][j]+C[i][j+1])%mod;
	}
}
int sum,L,R,f[N][N*N];
void ins(int x){
	sum+=x;
	for(int i=n;i>=1;i--)for(int j=sum;j>=x;j--)reduce(f[i][j]+=f[i-1][j-x]);
}
void del(int x){
	for(int i=1;i<=n;i++)for(int j=x;j<=sum;j++)Reduce(f[i][j]-=f[i-1][j-x]);
	sum-=x;
}
int solve1(int p){
	int ans=0,tot=0;
	for(int i=1;i<=n;i++)tot+=a[i]>p;
	for(;R<p;R++)for(int x=1;x<=cnt[R];x++)ins(R);
	for(;L<p-m;L++)for(int x=1;x<=cnt[L];x++)del(L);
	for(int i=0;i<=n;i++)for(int j=0;j<=sum;j++){
		// cerr<<p<<' '<<i<<' '<<j<<' '<<f[i][j]<<endl;
		int t=(v*m-(i*p-j));
		ans=(ans+1ll*f[i][j]*);
		if(i*p-j<=v*m)reduce(ans+=f[i][j]);
	}
	// cerr<<p<<' '<<L<<' '<<R<<endl;
	// cerr<<p<<' '<<ans<<endl;
	return 1ll*ans*(pw[cnt[p]]+mod-1)%mod;
}
void solve2(int p){
	int
}
void get(){
	scanf("%d%d%d",&n,&m,&v);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	mx=*max_element(a+1,a+1+n);
	fill(cnt,cnt+1+mx,0);
	for(int i=1;i<=n;i++)cnt[a[i]]++;
	int ans=0;
	L=1,R=1,sum=0;
	memset(f,0,sizeof f),f[0][0]=1;
	for(int i=1;i<=mx;i++)if(cnt[i]){
		(ans+=solve1(i))%=mod;
	}
	L=1,R=1,sum=0;
	memset(f,0,sizeof f),f[0][0]=1;
	for(int i=1;i<=mx;i++)if(cnt[i]){
		(ans+=solve2(i))%=mod;
	}
	printf("%d\n",ans);
}
int main(){
	init();
	for(scanf("%d",&T);T--;)get();
	return 0;
}

Details

answer.code: In function ‘int solve1(int)’:
answer.code:39:38: error: expected primary-expression before ‘)’ token
   39 |                 ans=(ans+1ll*f[i][j]*);
      |                                      ^
answer.code:44:25: error: ‘pw’ was not declared in this scope; did you mean ‘p’?
   44 |         return 1ll*ans*(pw[cnt[p]]+mod-1)%mod;
      |                         ^~
      |                         p
answer.code: In function ‘void solve2(int)’:
answer.code:48:1: error: expected unqualified-id before ‘}’ token
   48 | }
      | ^
answer.code: In function ‘void get()’:
answer.code:64:29: error: void value not ignored as it ought to be
   64 |                 (ans+=solve2(i))%=mod;
      |                       ~~~~~~^~~
answer.code:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |         scanf("%d%d%d",&n,&m,&v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:51:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   51 |         for(int i=1;i<=n;i++)scanf("%d",&a[i]);
      |                              ~~~~~^~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:70:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   70 |         for(scanf("%d",&T);T--;)get();
      |             ~~~~~^~~~~~~~~