QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#671838#8338. Quad Kingdoms ChesssjcxCompile Error//C++232.2kb2024-10-24 14:39:362024-10-24 14:39:36

Judging History

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

  • [2024-10-24 14:39:36]
  • 评测
  • [2024-10-24 14:39:36]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<random>
#include<ctime>
using namespace std;
#define re int
#define ll unsigned long long
inline int read(){
    int x=0,ff=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')ff=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
    return x*ff;
}
const int mn1=1e9+7;
const int b1=233;
const int B=600;
inline int md1(int x){return x>=mn1?x-mn1:x;}
int g1[100005];
struct H{
	int s,vl1,tp;
};
void cl(H &x,int y){
	x.s=1;x.vl1=1ll*y*b1%mn1;
	x.tp=y;
}
H add(H x,int y){
	H u;u.s=x.s+1;
	u.vl1=md1(1ll*x.vl1*b1%mn1+1ll*y*b1%mn1);
	u.tp=x.tp;return u;
}
H merge(H x,H y){
	H u;u.s=x.s+y.s;
	u.vl1=md1(1ll*x.vl1*g1[y.s]%mn1+y.vl1);
	u.tp=x.tp;return u;
}
void cle(vector<int> &qwq){
	vector<int> awa;swap(qwq,awa);
}
struct tt{
	int a[100005],n,m;
	H h[100005];
	vector<int>st[1000];
	void build(int i){
		int len=0;cle(st[i]);
		for(re j=(i-1)*B+1;j<=i*B&&j<=n;j++){
			while(len){
				if(a[st[i][len-1]]<a[j])st[i].pop_back(),len--;
				else break;
			}
			if(!len){
				st[i].emplace_back(j);
				len++;
				cl(h[j],a[j]);continue;
			}
			else {
				h[j]=add(h[st[i][len-1]],a[j]);
				len++;st[i].emplace_back(j);
			}
		}
	}
	void init(){
		n=read();
		m=(n-1)/B+1;
		for(re i=1;i<=n;i++)a[i]=read();
		for(re i=1;i<=m;i++)build(i);
	}
	void update(int x,int y){
		int u=(x-1)/B+1;
		if(!b[x]&&a[x]>=y){
			a[x]=y;return;
		}
		a[x]=y;build(u);
	}
	H ask(){
		H qwq=h[n];
		for(re i=m-1;i>0;i--){
			int l=0,r=st[i].size()-1,mid;
			if(a[st[i][0]]<qwq.tp)continue;
			while(l<=r){
				mid=(l+r)>>1;
				if(qwq.tp>a[st[i][mid]])r=mid-1;
				else l=mid+1;
			}
			l--;
			if(l>=0)qwq=merge(h[st[i][l]],qwq);
		}
		return qwq;
	}
}T[2];
int main(){
	g1[0]=1;
	for(re i=1;i<=100000;i++){
		g1[i]=1ll*g1[i-1]*b1%mn1;
	}
	T[0].init();
	T[1].init();
	int m=read(),t,x,y;
	while(m--){
		t=read();x=read();y=read();
		T[t-1].update(x,y);if(T[0].a[T[0].n]!=T[1].a[T[1].n]){puts("NO");continue;}
		H qwq=T[0].ask();H awa=T[1].ask();
		if(qwq.vl1==awa.vl1)puts("YES");
		else puts("NO");
	}
    return 0;
}

Details

answer.code: In member function ‘void tt::update(int, int)’:
answer.code:74:21: error: ‘b’ was not declared in this scope
   74 |                 if(!b[x]&&a[x]>=y){
      |                     ^