QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#261842#7761. 物理实验zhouhuanyi0 1463ms30552kbC++142.9kb2023-11-23 11:46:192023-11-23 11:46:20

Judging History

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

  • [2023-11-23 11:46:20]
  • 评测
  • 测评结果:0
  • 用时:1463ms
  • 内存:30552kb
  • [2023-11-23 11:46:19]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 200000
#define K 524288
#define M 20
#define g 3
#define mod 998244353
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
void Adder(int &x,int d)
{
	x+=d;
	if (x>=mod) x-=mod;
	return;
}
void Adder2(int &x,int d)
{
	x+=d;
	if (x<0) x+=mod;
	return;
}
int MD(int x)
{
	return x>=mod?x-mod:x;
}
int MD2(int x)
{
	return x<0?x+mod:x;
}
int fast_pow(int a,int b)
{
	int res=1,mul=a;
	while (b)
	{
		if (b&1) res=1ll*res*mul%mod;
		mul=1ll*mul*mul%mod,b>>=1;
	}
	return res;
}
int n,m,length,p,L,R,res,cnt[N+1],rev[K+1],wn[M+1][K+1],wn2[M+1][K+1],A[K+1],B[K+1],dp[N+1],num[K+1];
void NTT(int limit,int *s,int type)
{
	int s1,s2;
	for (int i=1;i<limit;++i) rev[i]=(rev[i>>1]>>1)|((i&1)?(limit>>1):0);
	for (int i=0;i<limit;++i)
		if (rev[i]>i)
			swap(s[i],s[rev[i]]);
	if (type==1)
	{
		for (int i=2;i<=limit;i<<=1)
			for (int j=0;j+i-1<limit;j+=i)
				for (int k=j;k<j+(i>>1);++k)
					s1=s[k],s2=1ll*s[k+(i>>1)]*wn[num[i]][k-j]%mod,s[k]=MD(s1+s2),s[k+(i>>1)]=MD2(s1-s2);
	}
	else
	{
		for (int i=2;i<=limit;i<<=1)
			for (int j=0;j+i-1<limit;j+=i)
				for (int k=j;k<j+(i>>1);++k)
					s1=s[k],s2=1ll*s[k+(i>>1)]*wn2[num[i]][k-j]%mod,s[k]=MD(s1+s2),s[k+(i>>1)]=MD2(s1-s2);
		for (int i=0;i<limit;++i) s[i]=1ll*s[i]*fast_pow(limit,mod-2)%mod;
	}
	return;
}
struct reads
{
	int d[N+1];
};
reads e,nw,nws,c,zero;
reads operator * (reads a,reads b)
{
	c=zero;
	int limit=1;
	while (limit<=(m<<2)) limit<<=1;
	for (int i=0;i<=limit;++i) A[i]=B[i]=0;
	for (int i=0;i<(m<<1);++i) A[i]=a.d[i],B[i]=b.d[i];
	NTT(limit,A,1),NTT(limit,B,1);
	for (int i=0;i<=limit;++i) A[i]=1ll*A[i]*B[i]%mod;
	NTT(limit,A,-1);
	for (int i=0;i<(m<<2);++i) Adder(c.d[i%(m<<1)],A[i]);
	return c;
}
reads fast_pow(reads a,int b)
{
	reads res=e,mul=a;
	while (b)
	{
		if (b&1) res=res*mul;
		mul=mul*mul,b>>=1;
	}
	return res;
}
int main()
{
	reads dst;
	int x,rst,limit=1;
	for (int i=2;i<=K;i<<=1)
	{
		num[i]=++length,rst=fast_pow(g,(mod-1)/i);
		for (int j=0,res=1;j<i;++j,res=1ll*res*rst%mod) wn[num[i]][j]=res;
		rst=fast_pow(g,(mod-1)/i*(i-1));
		for (int j=0,res=1;j<i;++j,res=1ll*res*rst%mod) wn2[num[i]][j]=res;
	}
	n=read(),m=read(),p=read(),L=read(),R=read(),e.d[0]=1,nw.d[1]=nw.d[(m<<1)-1]=1ll*p*MD2(1-p)%mod,nw.d[0]=MD(1ll*p*p%mod+1ll*MD2(1-p)*MD2(1-p)%mod);
	for (int i=1;i<=n;++i) x=read(),cnt[x]++;
	while (limit<=m) limit<<=1;
	for (int i=0;i<m;++i) A[i]=cnt[i],B[m-i]=cnt[i];
	NTT(limit,A,1),NTT(limit,B,1);
	for (int i=0;i<=limit;++i) A[i]=1ll*A[i]*B[i]%mod;
	NTT(limit,A,-1);
	for (int i=1;i<m;++i) nws.d[i]=A[m+i];
	dst=nws*fast_pow(nw,L-1);
	for (int i=L;i<=R;++i)
	{
		dst=dst*nw,res=0;
		for (int j=1;j<m;++j) Adder(res,1ll*dst.d[j]*min(j,m-j)%mod),Adder2(res,-1ll*dst.d[j+m]*min(j,m-j)%mod);
		printf("%d ",res);
	}
	puts("");
	return 0;
}

詳細信息

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

7500 7500 96132844 1 7500
1791 817 5559 4742 5272 3988 6672 1355 2783 5552 6885 5321 5996 6495 3072 2241 5527 856 6250 2741 4223 1560 6529 5330 3517 2637 6577 244 1739 5147 2648 6466 1479 7340 7355 176 183 1417 2943 5134 3879 3574 734 4880 7451 3778 1466 5237 2015 1334 6105 4859 1331 5805 3175 4795 ...

output:

682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 682734915 ...

result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 331ms
memory: 27500kb

input:

100000 7500 500440646 935892941 935892941
3280 7218 1216 489 4036 7029 5538 4805 2544 568 4303 816 739 2284 1294 6062 808 3029 3565 4344 7124 3917 705 3637 6076 2019 4233 2032 7327 5672 2872 2593 22 1534 2071 5782 3228 5460 1217 5138 7285 3679 2751 213 2242 2673 2746 7041 7001 860 2591 7347 3330 213...

output:

252719482 

result:

wrong answer 1st numbers differ - expected: '768801558', found: '252719482'

Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Wrong Answer

Test #9:

score: 0
Wrong Answer
time: 1463ms
memory: 30552kb

input:

100000 50000 559705157 50000 50000
27437 48841 4744 41269 30017 24703 22660 38617 9707 42083 31500 14053 45335 20769 16455 30887 31847 6833 44822 14557 15400 18868 15093 47184 35490 48961 45686 45613 297 31598 7021 9194 30432 14570 44495 39114 21800 16034 12668 49738 20083 31717 22713 34958 46363 35...

output:

242249978 

result:

wrong answer 1st numbers differ - expected: '397469689', found: '242249978'

Subtask #6:

score: 0
Skipped

Dependency #2:

0%

Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Skipped

Dependency #7:

0%

Subtask #9:

score: 0
Skipped

Dependency #6:

0%

Subtask #10:

score: 0
Skipped

Dependency #4:

0%