QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#664731#4322. rsraogps / 雪に咲く花DengDuckWA 670ms91648kbC++141.6kb2024-10-21 22:02:552024-10-21 22:02:56

Judging History

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

  • [2024-10-21 22:02:56]
  • 评测
  • 测评结果:WA
  • 用时:670ms
  • 内存:91648kb
  • [2024-10-21 22:02:55]
  • 提交

answer

#include<bits/stdc++.h>
#define int unsigned int 
using namespace std;
const int SIZE=(1<<20)+1;
char BF[SIZE],BFO[SIZE],*P1=BF,*P2=BF;
int op=-1;
const int op2=SIZE-1;
inline char GC()
{
	if(P1!=P2)return *P1++;
	return P1==(P2=(P1=BF)+fread(BF,1,SIZE-1,stdin))?EOF:*P1++;
}
inline void FF(){fwrite(BFO,1,op+1,stdout),op=-1;}
inline void PC(const char &c)
{
	if(op==op2)FF();
	BFO[++op]=c;
}
inline void Rd(int &s)
{
	s=0;char ch=GC();
	while(ch<'0'||ch>'9')ch=GC();
	while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch-'0');ch=GC();}
}
inline void Print(int x)
{
	char S[25];int t=0;
	while(x||!t)S[++t]=x%10+'0',x/=10;
	for(int i=t;i>=1;i--)PC(S[i]);
	PC('\n');
}
const int N=1e6+5;
const int M=5e6+5;
int n,m,A[N],B[N],C[N],Ans[M],H[N];
int V[N],S[N],Lst[N],Now;
int L[M],Nxt[M];
inline int Qry(int i,int x){return V[x]+S[x]*(i-Lst[x]);}
signed main()
{
	Rd(n),Rd(m);
	for(int i=1;i<=n;i++)Rd(A[i]);
	for(int i=1;i<=n;i++)Rd(B[i]);
	for(int i=1;i<=n;i++)Rd(C[i]);
	for(int i=1,R;i<=m;i++)
	{
		Rd(L[i]),Rd(R);
		Nxt[i]=H[R],H[R]=i;
	}
	for(int i=1,j;i<=n;i++)
	{
		for(j=i-1;j;j--)
		{
			int V1=A[j]&A[j+1];
			int V2=B[j]|B[j+1];
			int V3=__gcd(C[j],C[j+1]);
			if(V1==A[j]&&V2==B[j]&&V3==C[j])break;
			A[j]=V1,B[j]=V2,C[j]=V3;
		}
		V[i]=Qry(i-1,i-1);//V[i] 是历史上的前缀和,所以要先继承 i-1
		for(int x=j+1;x<=i;x++)
		{
			V[x]=Qry(i-1,x);//前缀和要更新了,计算新的历史和
			S[x]=S[x-1]+A[x]*B[x]*C[x],Lst[x]=i-1;
		}
		for(int x=H[i];x;x=Nxt[x])
		{
			Ans[x]=Qry(i,i)-Qry(i,L[x]-1);		
		}
	}
	for(int i=1;i<=m;i++)Print(Ans[i]),PC('\n');
	FF();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 670ms
memory: 91648kb

input:

1000000 4999998
677759 16844 194149 882507 258413 301124 335220 853562 556891 940146 265534 89372 852421 821748 453468 389493 767295 749954 967376 543995 891396 399529 837606 300380 188426 701042 209657 534843 857430 548210 681875 715389 276811 492296 717786 463046 233941 281371 641808 990695 702677...

output:

3578099829

247368737

4134953488

123772255

4271316421

2664004035

1981625521

4161064085

2301764273

3633218207

446408196

4089220553

2146535877

2604957438

3629218607

861849275

2324734025

926506509

652453278

2182055877

4151704810

1597517111

4271912484

2355275472

3461746888

548698...

result:

wrong answer 2nd lines differ - expected: '247368737', found: ''