QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#668442#9242. An Easy Geometry Problemucup-team4352Compile Error//C++232.5kb2024-10-23 14:25:182024-10-23 14:25:28

Judging History

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

  • [2024-10-23 14:25:28]
  • 评测
  • [2024-10-23 14:25:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=2000223479;
int n,q,k,b,a[maxn],opt,l,r,p;
typedef long long ll;
ll qp[maxn],tmp[maxn],c[maxn];
void Init() {
	qp[0]=1;
	for(int i=1;i<=n;++i) {
		qp[i]=qp[i-1]*1373%mod;
		tmp[i]=(tmp[i-1]+qp[i-1])%mod;
	}
}
struct Node{
	ll sum[maxn<<2];
	int lazy[maxn<<2];
	void add(ll &x,int y) {
		x+=y;
		if(x>=mod) x-=mod;
	}
	void pushup(int rt,int l,int r) {
		int mid=l+r>>1;
		sum[rt]=(sum[rt<<1]*qp[r-mid]+sum[rt<<1|1])%mod;
	}
	void pushdown(int rt,int l,int r) {
		if(lazy[rt]) {
			int x=lazy[rt];
			lazy[rt]=0;
			add(lazy[rt<<1],x),add(lazy[rt<<1|1],x);
			int mid=l+r>>1;
			sum[rt<<1]=(sum[rt<<1]+tmp[mid-l+1]*x)%mod;
			sum[rt<<1|1]=(sum[rt<<1|1]+tmp[r-mid]*x)%mod;
		}
		return;
	}
	void build(int rt,int l,int r) {
		if(l==r) {
			sum[rt]=c[l];
			return;
		}
		int mid=l+r>>1;
		build(rt<<1,l,mid);
		build(rt<<1|1,mid+1,r);
		pushup(rt,l,r);
	}
	void update(int rt,int l,int r,int L,int R,int k) {
		if(L<=l&&R>=r) {
			int len=r-l+1;
			add(lazy[rt],k);
			sum[rt]=(sum[rt]+(ll)k*tmp[len])%mod;
			return;
		}
		pushdown(rt,l,r);
		int mid=l+r>>1;
		if(L<=mid) update(rt<<1,l,mid,L,R,k);
		if(R>mid) update(rt<<1|1,mid+1,r,L,R,k);
		pushup(rt,l,r);
	}
	ll query(int rt,int l,int r,int L,int R) {
		if(L<=l&&R>=r) return sum[rt];
		pushdown(rt,l,r);
		int mid=l+r>>1;
		ll res=0;
		if(L<=mid) res=query(rt<<1,l,mid,L,R);
		if(R>mid) res=(res*qp[max(0,min(r,R)-mid)]+query(rt<<1|1,mid+1,r,L,R))%mod;;
		pushup(rt,l,r);
		return res;
	}
}T1,T2;
bool solve(int p,int mid) {
	if(T1.query(1,1,n,p-mid,p-1)==T2.query(1,1,n,n-p-mid+1,n-p)) return 1;
	return 0;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>q>>k>>b;
	Init();
	if(k<0) k+=mod;
	if(b<0) b+=mod;
	for(int i=1;i<=n;++i) {
		cin>>a[i];
		if(a[i]<0) a[i]+=mod;
		c[i]=((ll)a[i]*2-(ll)k*i)%mod;
		if(c[i]<0) c[i]+=mod;
	}
	T1.build(1,1,n);
	reverse(c+1,c+1+n);
	for(int i=1;i<=n;++i) c[i]=(c[i]-2ll*b+2ll*mod)%mod;
	T2.build(1,1,n);
	while(q--) {
		cin>>opt;
		if(opt==1) {
			cin>>l>>r>>p;
			if(p<0) p+=mod;
			T1.update(1,1,n,l,r,2ll*p%mod);
			T2.update(1,1,n,n-r+1,n-l+1,2ll*p%mod);
		}
		else {
			cin>>p;
			l=1,r=min(p-1,n-p);
			while(l<=r) {
				int mid=l+r>>1;
				if(solve(p,mid)) l=mid+1;
				else r=mid-1;
			}
			cout<<r<<'\n';
		}
	}
	return 0;
}
/*
 6 6 6 2
 1 5 9 10 15 18
 2 2
 1 3 3 -3
 2 2
 1 3 4 3
 2 3
 2 4
*/

詳細信息

answer.code: In member function ‘void Node::pushdown(int, int, int)’:
answer.code:30:39: error: cannot bind non-const lvalue reference of type ‘ll&’ {aka ‘long long int&’} to a value of type ‘int’
   30 |                         add(lazy[rt<<1],x),add(lazy[rt<<1|1],x);
      |                             ~~~~~~~~~~^
answer.code:18:22: note:   initializing argument 1 of ‘void Node::add(ll&, int)’
   18 |         void add(ll &x,int y) {
      |                  ~~~~^
answer.code:30:60: error: cannot bind non-const lvalue reference of type ‘ll&’ {aka ‘long long int&’} to a value of type ‘int’
   30 |                         add(lazy[rt<<1],x),add(lazy[rt<<1|1],x);
      |                                                ~~~~~~~~~~~~^
answer.code:18:22: note:   initializing argument 1 of ‘void Node::add(ll&, int)’
   18 |         void add(ll &x,int y) {
      |                  ~~~~^
answer.code: In member function ‘void Node::update(int, int, int, int, int, int)’:
answer.code:50:36: error: cannot bind non-const lvalue reference of type ‘ll&’ {aka ‘long long int&’} to a value of type ‘int’
   50 |                         add(lazy[rt],k);
      |                             ~~~~~~~^
answer.code:18:22: note:   initializing argument 1 of ‘void Node::add(ll&, int)’
   18 |         void add(ll &x,int y) {
      |                  ~~~~^