QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768369#8338. Quad Kingdoms ChessDepletedPrismWA 2ms10368kbC++231.9kb2024-11-21 09:49:572024-11-21 09:49:58

Judging History

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

  • [2024-11-21 09:49:58]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:10368kb
  • [2024-11-21 09:49:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define ent putchar('\n')
#define spc putchar(' ')
#define pb push_back
#define fi first
#define se second
inline void read(int &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
inline void lread(long long &num){num=0;int f=1;char ch=getchar();while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){num=(num<<1)+(num<<3)+(ch^48);ch=getchar();}num*=f;}
void print(long long num){if(num<0){putchar('-');num=-num;}if(num>9){print(num/10);}putchar((num%10)^48);}
const int N=1e5+9;
mt19937_64 rnd(time(0));
ULL mp[N];
struct Segtree{
	int t[N<<2];
	ULL ct[N<<2];
	ULL solve(int p,int mx,int l,int r){
		if(l==r){
			if(t[p]>=mx)return ct[p];
			else return 0;
		}
		int mid=l+r>>1;
		if(t[p<<1|1]>=mx)return solve(p<<1|1,mx,mid+1,r)+ct[p]-ct[p<<1|1];
		else return solve(p<<1,mx,l,mid);
	}
	void build(int p,int l,int r){
		if(l==r){
			read(t[p]);
			ct[p]=mp[t[p]];
			return;
		}
		int mid=l+r>>1;
		build(p<<1,l,mid),build(p<<1|1,mid+1,r);
		t[p]=max(t[p<<1],t[p<<1|1]);
		ct[p]=ct[p<<1|1]+solve(p<<1,t[p<<1|1],l,mid);
	}
	void change(int p,int l,int r,int x,int y){
		if(l==r){
			t[p]=y;
			ct[p]=mp[t[p]];
			return;
		}
		int mid=l+r>>1;
		if(x<=mid)change(p<<1,l,mid,x,y);
		else change(p<<1|1,mid+1,r,x,y);
		t[p]=max(t[p<<1],t[p<<1|1]);
		ct[p]=ct[p<<1|1]+solve(p<<1,t[p<<1|1],l,mid);
	}
}t1,t2;
int main(){
	for(int i=1;i<=1e5;i++)mp[i]=rnd();
	int n,m,T,mod,x,y;
	read(n);
	t1.build(1,1,n);
	read(m);	
	t2.build(1,1,m);
	read(T);
	while(T--){
		read(mod),read(x),read(y);
		if(mod-1)t2.change(1,1,m,x,y);
		else t1.change(1,1,n,x,y);
		if(t1.ct[1]==t2.ct[1])puts("Yes");
		else puts("NO");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 10368kb

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:

wrong answer 4th words differ - expected: 'YES', found: 'Yes'