QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#735#347038#8338. Quad Kingdoms Chess114514abcucup-team1004Failed.2024-07-11 22:25:242024-07-11 22:25:25

詳細信息

Extra Test:

Invalid Input

input:

114514

output:


result:

FAIL Integer 114514 violates the range [1, 100000] (stdin, line 1)

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#347038#8338. Quad Kingdoms Chessucup-team1004#AC ✓142ms21168kbC++142.3kb2024-03-09 10:15:222024-03-09 10:15:22

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e5+5,M=N*4+5,K=1000+5,mod=1e9+9,Mod=mod-1;const db eps=1e-9;const ll INF=2e18+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m,A[N],B[N];ull val[N];
struct Tree{
	#define ls v<<1
	#define rs v<<1|1
	int mx[M];ull f[M],sum[M];
	ull find(int x,int l,int r,int v){
		if(l==r) return mx[v]>=x?val[mx[v]]:0ull;
		int m=l+r>>1;if(mx[rs]<x) return find(x,l,m,ls);
		return f[v]+find(x,m+1,r,rs);
	}
	void up(int v,int l,int r){
		mx[v]=max(mx[ls],mx[rs]);
		f[v]=find(mx[rs],l,l+r>>1,ls);sum[v]=sum[rs]+f[v];
	}
	void build(int *A,int l,int r,int v=1){
		if(l==r){mx[v]=A[l];sum[v]=f[v]=val[A[l]];return;}
		int m=l+r>>1;build(A,l,m,ls);build(A,m+1,r,rs);up(v,l,r);
	}
	void modify(int x,int y,int l,int r,int v=1){
		if(l==r){mx[v]=y;sum[v]=f[v]=val[y];return;}
		int m=l+r>>1;x<=m?modify(x,y,l,m,ls):modify(x,y,m+1,r,rs);up(v,l,r);
	}
}f1,f2;
void Solve(){
	int i,j;mt19937_64 rnd(26302);
	for(i=1;i<=1e5;i++) val[i]=rnd();
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&A[i]);f1.build(A,1,n);
	scanf("%d",&m);
	for(i=1;i<=m;i++) scanf("%d",&B[i]);f2.build(B,1,m);
	int q;scanf("%d",&q);while(q--){
		int op,x,y;scanf("%d%d%d",&op,&x,&y);
		if(op==1) f1.modify(x,y,1,n);
		else f2.modify(x,y,1,m);
		puts(f1.sum[1]==f2.sum[1]?"YES":"NO");
		// gdb(f1.sum[1],f2.sum[1]);
	}
}
int main(){
	int t=1;
	// scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}