QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#122499#5530. No Zero-Sum Subsegmentc20230139WA 18ms35060kbC++141.1kb2023-07-10 16:54:132023-07-10 16:54:16

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-10 16:54:16]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:35060kb
  • [2023-07-10 16:54:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e6+5,mod=998244353;
int qpow(int a,int b) {
	int ans=1;
	while(b) {
		if(b&1)ans=ans*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return ans;
}
int inv[N],fac[N];
int f(int len,int x,int y,int z) {
	z-=2*x;
	if(x>=0&&y>=0&&z>=0)return len*fac[x+y+z]*inv[x]%mod*inv[y]%mod*inv[z]%mod;
	return 0;
} 
int solve() {
	int a,b,c,d;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	int S=-2*a-b+c+2*d,ans=0;
	if(!S) return 0;
	if(S<0) swap(a,d),swap(b,c);
	if(!a) return (f(1,b,c,d)+f(2,b-1,c,d-1)+f(1,b-2,c,d-2))%mod;
	(ans+=f(a+1,b-2,c,d-a-2))%=mod;
	(ans+=f(a,b-1,c-1,d-a-1))%=mod;
	(ans+=f(a,b-1,c-1,d-a-1))%=mod;
	(ans+=f(a-1,b,c-2,d-a))%=mod;
	(ans+=f(1,b-1,c,d-a-1))%=mod;
	(ans+=f(1,b,c-1,d-a))%=mod;
	(ans+=f(1,b-1,c,d-a-1))%=mod;
	(ans+=f(1,b,c-1,d-a))%=mod;//对称
	return ans; 
}
signed main() {
	fac[0]=1;
	for(int i=1;i<N;i++)fac[i]=fac[i-1]*i%mod;
	inv[N-1]=qpow(fac[N-1],mod-2);
	for(int i=N-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	int T;
	scanf("%lld",&T);
	while(T--) printf("%lld\n",solve());
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 18ms
memory: 35060kb

input:

5
69 0 0 0
1 1 1 1
0 0 3 3
6 1 0 6
10000 10000 1000000 1000000

output:

1
0
20
2
307957211

result:

wrong answer 5th numbers differ - expected: '480402900', found: '307957211'