QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#488011#4322. rsraogps / 雪に咲く花_FJqwqCompile Error//C++141.3kb2024-07-23 14:56:162024-07-23 14:56:16

Judging History

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

  • [2024-07-23 14:56:16]
  • 评测
  • [2024-07-23 14:56:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define uint unsigned int
const int N=1e6+5;
uint n,q,a[N],b[N],c[N],ans[N*5],pre[N],las[N],val[N],pwp;
uint L[N*5],R[N*5],id[N*5],cnt[N];
uint ask(int x){return pre[x]*(pwp-las[x])+val[x];}
char *p1,*p2,buf[5000005];
#define nc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,5000000,stdin),p1==p2)?EOF:*p1++)
uint read(){
	uint x=0;char ch=nc();
	while(ch<48||ch>57)ch=nc();
	while(ch>=48&&ch<=57){x=x*10+ch-48,ch=nc();}
	return x;
}
void write(uint x){
	if(x<0){putchar('-');x=-x;}
	if(x>9)write(x/10);putchar(x%10+'0');
}
int main(){
	n=read(),q=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=read();
	for(int i=1;i<=n;i++) c[i]=read();
	for(int i=1;i<=q;i++) L[i]=read(),cnt[R[i]=read()]++;
	for(int i=1;i<=n+1;i++) cnt[i]+=cnt[i-1];
	for(int i=1;i<=q;i++) id[cnt[R[i]]--]=i;
	uint v1,v2,v3;
	for(int i=1,j;i<=n;i++){
		for(j=i-1;j;j--){
			v1=(a[j]&a[j+1]);
			v2=(b[j]|b[j+1]);
			v3=gcd(c[j],c[j+1]);
			if(v1==a[j])
				if(v2==b[j])
					if(v3==c[j])
						break;
			a[j]=v1,b[j]=v2,c[j]=v3;
		}
		val[i]=ask(i-1);
		for(j++;j<=i;j++){
			val[j]=ask(j);
			pre[j]=pre[j-1]+a[j]*b[j]*c[j];
			las[j]=pwp;
		}
		pwp++;
		for(j=cnt[i]+1;j<=cnt[i+1];j++)
			ans[id[j]]=ask(i)-ask(L[id[j]]-1);
	}
	for(int i=1;i<=q;i++) write(ans[i]),putchar('\n');
	return 0;
}


详细

answer.code: In function ‘int main()’:
answer.code:33:28: error: ‘gcd’ was not declared in this scope
   33 |                         v3=gcd(c[j],c[j+1]);
      |                            ^~~