QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708531#4903. 细菌TheZoneCompile Error//C++209.9kb2024-11-03 23:13:512024-11-03 23:13:51

Judging History

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

  • [2024-11-03 23:13:51]
  • 评测
  • [2024-11-03 23:13:51]
  • 提交

answer

#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC target("avx,avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,fast-math")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
//#include<iostream>
//#include<string>
//#include<cmath>
//#include<cstdio>
//#include<cctype>
//#include<cstring>
//#include<iomanip>
//#include<cstdlib>
//#include<ctime>
//#include<set>
//#include<map>
//#include<utility>
//#include<queue>
//#include<vector>
//#include<stack>
//#include<sstream>
//#include<algorithm>
using namespace std;
/*=====================================================================*/
#define ll long long
#define int ll
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pdd pair<double,double>
#define ull unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(s) (s).begin(),(s).end()
#define repd(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define forr(i,a,b,c) for(int i=(int)(a);i<=(int)(b);i+=(int)(c))
#define forn(i,p,n) for(int i=(int)(p);i<=(int)(n);++i)
#define ford(i,p,n) for(int i=(int)(n);i>=(int)(p);--i)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define Endl(x) cout<<x<<endl;
#define Blank(x) cout<<x<<" ";
#define modcg(x) if(x>=mod)x-=mod;
#define modcl(x) if(x<0)x+=mod;
#define lowbit(x) x&(-x)
/*=====================================================================*/
string int_to_string(ll n)
{
	string s="";
	while(n)
	{
		ll now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
ll string_to_int(string s)
{
	ll n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
mt19937 GeN(chrono::system_clock::now().time_since_epoch().count());
int Rand(int l,int r)
{
	uniform_int_distribution<>RAND1(l,r);
	return RAND1(GeN);
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
//think twice,code once
//think once,debug forever
const int MAXN=480020;
const int mod=998244353,gen=3,igen=332748118;
int quickpower(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
int inv(int x)
{
	return quickpower(x,mod-2);
}
struct Poly
{
	int r[MAXN];
	int limit,l,invl;
	void init(int n)
	{
		l=0;
		limit=1;
		while(limit<n)
		{
			limit<<=1;
			l++; 
		}
		invl=::inv(limit);
		rep(i,limit)
		{
			r[i]=(r[i>>1]>>1ll)|((i&1ll)<<(l-1));
		}
	}
	void NTT(vi &a,bool type)
	{
		a.resize(limit);
		rep(i,limit) 
		{
			if(i<r[i])
			{
				swap(a[i],a[r[i]]);
			}
		}
		for(int i=2;;i<<=1)
		{
			if(i>limit)
			{
				break;
			}
			int Gen=quickpower(((type==1)?gen:igen),(mod-1)/i);
			forr(j,0,limit-1,i)
			{
				int w=1;
				forn(k,j,(i>>1)+j-1)
				{
					int cur=w*a[k+(i>>1)]%mod;
					a[k+(i>>1)]=((a[k]-cur)%mod+mod)%mod;
					a[k]=(a[k]+cur)%mod;
					w*=Gen;
					w%=mod;
				}
			}
		}
	}
	vi mul(vi f,vi g)
	{
		int n=f.size();
		int m=g.size();	
		init(n+m);
		NTT(f,1);
		NTT(g,1);
		rep(i,limit)
		{
			f[i]=f[i]*g[i]%mod*invl%mod;
		}
		NTT(f,0);
		f.resize(n+m);
		return f;
	}
	vi inv(vi f)
	{
		if(f.size()==1)
		{
			f[0]=::inv(f[0]);
			return f;
		}
		int all=f.size();
		vi nf=f;
		nf.resize((all+1)/2);	
		nf=inv(nf);
		vi nf1=nf;
		nf1=mul(nf1,f);
		nf1.resize(all);
		rep(i,nf1.size())
		{
			nf1[i]=-nf1[i];
			modcl(nf1[i]);
		}
		nf1[0]+=2;
		modcg(nf1[0]);
		f=mul(nf,nf1);
		f.resize(all);
		return f;
	}
}P;
struct combination
{
	int F[MAXN],invF[MAXN];
	int P[MAXN];
	void init(int n)
	{
		F[0]=1;
		P[0]=1;
		forn(i,1,n)
		{
			F[i]=(F[i-1]*i)%mod;
			P[i]=P[i-1]+P[i-1];
			modcg(P[i]);
		}
		invF[n]=inv(F[n]);
		ford(i,0,n-1)
		{
			invF[i]=(invF[i+1]*(i+1))%mod;
		}
	}
	int C(int n,int m)
	{
		if(n<0||m<0||n<m)
		{
			return 0;
		}
		return ((F[n]*invF[m])%mod*invF[n-m])%mod;
	}
	int A(int n,int m)
	{
		if(n<0||m<0||n<m)
		{
			return 0;
		}
		return F[n]*invF[n-m]%mod;
	}
}C;
int n[3];
int x[3];
int d;
vi ans[3];
void doit(int id)
{
	vi S,A;
	S.resize(d+1);
	A.resize(d+1);
	int a=x[id],b=n[id]+1-x[id];
	forn(i,1,d)
	{
		if((i-a>=0)&&(!((i-a)&1)))
		{
			S[i]+=C.C(i,(i-a)>>1);
			modcg(S[i]);
		}
		if((i-b>=0)&&(!((i-b)&1)))
		{
			S[i]+=C.C(i,(i-b)>>1);
			modcg(S[i]);
		}
		if(!(i&1))
		{
			A[i]+=C.C(i,i>>1);
			modcg(A[i]);
		}
		if((i-n[id]-1>=0)&&(!((i-n[id]-1)&1)))
		{
			A[i]+=C.C(i,(i-n[id]-1)>>1);
			modcg(A[i]);
		}
	}
	A[0]=1;
//	S[0]=0;
//	for(int u:A)
//	{
//		cout<<u<<" ";
//	}
//	cout<<endl;
//	for(int u:S)
//	{
//		cout<<u<<" ";
//	}
//	cout<<endl;
	A=P.inv(A);
	ans[id]=P.mul(A,S);
	ans[id].resize(d+1);
//	for(int u:ans[id])
//	{
//		cout<<u<<" ";
//	}
//	cout<<endl; 
	ans[id][0]=C.P[0];
	forn(i,1,d)
	{
		ans[id][i]=-ans[id][i];
		modcl(ans[id][i]);
		ans[id][i]+=ans[id][i-1];
		modcg(ans[id][i]);
		ans[id][i]+=ans[id][i-1];
		modcg(ans[id][i]);
	}
	forn(i,0,d)
	{
		ans[id][i]*=C.invF[i];
		ans[id][i]%=mod;
//		cout<<ans[id][i]<<" ";
	}
//	cout<<endl;
}
void solve()
{
	cin>>d;
	rep(i,3)
	{
		cin>>n[i];	
	}
	rep(i,3)
	{
		cin>>x[i];
	}
	C.init(d);
	rep(i,3)
	{
		doit(i);
	}
//	rep(i,3)
//	{
//		for(int u:ans[i])
//		{
//			cout<<u<<" ";
//		}
//		cout<<endl;
//	}
	ans[0]=P.mul(ans[0],ans[1]);
	ans[0].resize(d+1);
	ans[0]=P.mul(ans[0],ans[2]);
	int ANS=ans[0][d]*C.F[d]%mod;
	cout<<ANS<<endl;
}
/*======================================================================*/
signed main()
{
    cin.tie(0);
    cout.tie(0);
	std::ios::sync_with_stdio(false);
//#define Hank2007
#ifdef Hank2007
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
  	/*====================================================================*/
  	int TEST_CASE=1;
//	cin>>TEST_CASE;
  	while(TEST_CASE--)
  	{
  		solve();
  	}
  	return 0;
}













































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Details

answer.code:23:39: warning: bad option ‘-fwhole-program’ to pragma ‘optimize’ [-Wpragmas]
   23 | #pragma GCC optimize("-fwhole-program")
      |                                       ^
answer.code:31:41: warning: bad option ‘-fstrict-overflow’ to pragma ‘optimize’ [-Wpragmas]
   31 | #pragma GCC optimize("-fstrict-overflow")
      |                                         ^
answer.code:33:41: warning: bad option ‘-fcse-skip-blocks’ to pragma ‘optimize’ [-Wpragmas]
   33 | #pragma GCC optimize("-fcse-skip-blocks")
      |                                         ^
answer.code:47:51: warning: bad option ‘-funsafe-loop-optimizations’ to pragma ‘optimize’ [-Wpragmas]
   47 | #pragma GCC optimize("-funsafe-loop-optimizations")
      |                                                   ^
answer.code:94:26: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
   94 | string int_to_string(ll n)
      |                          ^
answer.code:94:26: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:94:26: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:94:26: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:106:26: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  106 | ll string_to_int(string s)
      |                          ^
answer.code:106:26: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:106:26: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:106:26: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:117:21: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  117 | int Rand(int l,int r)
      |                     ^
answer.code:117:21: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:117:21: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:117:21: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:130:27: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  130 | int quickpower(int a,int b)
      |                           ^
answer.code:130:27: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:130:27: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:130:27: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:146:14: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  146 | int inv(int x)
      |              ^
answer.code:146:14: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:146:14: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:146:14: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:154:24: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  154 |         void init(int n)
      |                        ^
answer.code:154:24: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:154:24: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:154:24: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:169:33: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  169 |         void NTT(vi &a,bool type)
      |                                 ^
answer.code:169:33: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:169:33: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:169:33: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:200:25: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  200 |         vi mul(vi f,vi g)
      |                         ^
answer.code:200:25: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:200:25: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:200:25: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimize’ [-Wattributes]
answer.code:215:20: warning: bad option ‘-fwhole-program’ to attribute ‘optimize’ [-Wattributes]
  215 |         vi inv(vi f)
      |                    ^
answer.code:215:20: warning: bad option ‘-fstrict-overflow’ to attribute ‘optimize’ [-Wattributes]
answer.code:215:20: warning: bad option ‘-fcse-skip-blocks’ to attribute ‘optimize’ [-Wattributes]
answer.code:215:20: warning: bad option ‘-funsafe-loop-optimizations’ to attribute ‘optimiz...