QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#463289#8338. Quad Kingdoms ChessPlentyOfPenalty#WA 29ms16972kbC++202.1kb2024-07-04 16:59:522024-07-04 16:59:52

Judging History

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

  • [2024-07-04 16:59:52]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:16972kb
  • [2024-07-04 16:59:52]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define log(...) (void(0))
#define endl '\n'
#endif
using namespace std;
typedef unsigned un;
const int MAXN = 100011,p1=1e9+7,p2=1e9+9,base=131131;
struct Hash
{
	int x,y;
	Hash(){x=y=0;}
	Hash(int _x,int _y){x=_x,y=_y;}
	Hash operator+(const Hash &rhs)const
	{
		Hash res;
		res.x=(x+rhs.x)%p1;
		res.y=(y+rhs.y)%p2;
		return res;
	}
	Hash operator*(const Hash &rhs)const
	{
		Hash res;
		res.x=1ll*x*rhs.x%p1;
		res.y=1ll*y*rhs.y%p2;
		return res;
	}
	bool operator== (const Hash& rhs){return x==rhs.x&&y==rhs.y;}
}pw[MAXN],B(base,base);
struct Segment_Tree
{
	struct node
	{
		int maxv,len;
		Hash h;
		node merge(const node& rhs)const
		{
			node res;
			res.maxv=max(maxv,rhs.maxv);
			res.len=len+rhs.len;
			res.h=h*pw[rhs.len]+rhs.h;
			return res;
		}
	}t[MAXN<<2|1];
	#define rt t[num]
	#define tl t[num<<1]
	#define tr t[num<<1|1]
	node get(int val,un l,un r,un num)
	{
		if(l==r)return rt;
		un mid=(l+r)>>1;
		if(tr.maxv>=val)
		{
			return tl.merge(get(val,mid+1,r,num<<1|1));
		}
		return get(val,l,mid,num<<1);
	}
	void pushup(un l,un r,un num=1)
	{
		if(tl.maxv<tr.maxv){rt=tr;return;}
		un mid=(l+r)>>1;
		node tmp=get(tr.maxv,l,mid,num<<1);
		rt=tmp.merge(tr);
	}
	void modify(un pos,int val,un l,un r,un num)
	{
		if(l==r)
		{
			rt.maxv=val,rt.len=1,rt.h=Hash(val,val);
			return;
		}
		un mid=(l+r)>>1;
		if(pos<=mid)modify(pos,val,l,mid,num<<1);
		else modify(pos,val,mid+1,r,num<<1|1);
		pushup(l,r,num);
		return;
	}
}t1,t2;
int a[MAXN],b[MAXN];
int main() {
#ifdef memset0
  freopen("K.in", "r", stdin);
#endif
  cin.tie(0)->sync_with_stdio(0);
	int n1,n2;
	cin>>n1;
	for(int i=1;i<=n1;++i)cin>>a[i],t1.modify(i, a[i], 1, n1, 1);
	cin>>n2;
	for(int i=1;i<=n2;++i)cin>>b[i],t2.modify(i, b[i], 1, n2, 1);
	int m;
	cin>>m;
	while(m--)
	{
		int o,x,y;
		cin>>o>>x>>y;
		if(o==1)t1.modify(x,y,1,n1,1);
		else t2.modify(x,y,1,n2,1);
		puts(t1.t[1].h==t2.t[1].h?"YES":"NO");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 16972kb

input:

5
1 2 3 4 5
5
5 4 3 2 1
8
1 1 5
1 4 2
1 2 4
1 5 1
1 5 5
2 1 4
2 3 5
2 5 5

output:

NO
NO
NO
YES
NO
NO
NO
YES

result:

ok 8 tokens

Test #2:

score: -100
Wrong Answer
time: 29ms
memory: 16892kb

input:

1
2
6
2 1 1 1 1 1
200000
2 6 2
1 1 1
1 1 1
1 1 2
2 1 1
1 1 2
1 1 1
2 4 1
2 1 2
1 1 1
1 1 2
2 5 1
1 1 1
1 1 2
1 1 1
2 6 1
1 1 2
1 1 2
1 1 2
2 3 1
1 1 1
2 1 1
2 6 2
1 1 2
2 4 1
1 1 2
2 6 1
1 1 2
1 1 1
2 5 2
2 6 2
1 1 1
2 4 2
2 5 2
2 6 2
1 1 1
2 5 1
2 6 2
1 1 2
1 1 1
1 1 1
2 4 1
1 1 2
1 1 2
1 1 2
2 3 2...

output:

YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
YES
NO
YES
NO
YES
NO
NO
NO
NO
YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
YES
NO
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
NO
YE...

result:

wrong answer 1st words differ - expected: 'NO', found: 'YES'