QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#718102#8338. Quad Kingdoms Chessicpc_zhzx034WA 23ms25076kbC++142.5kb2024-11-06 19:42:222024-11-06 19:42:22

Judging History

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

  • [2024-11-06 19:42:22]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:25076kb
  • [2024-11-06 19:42:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pr;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
// #define mid ((l+r)>>1)
#define popcnt __builtin_popcountll
inline ll read(){
	ll x=0, f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0' && ch<='9') x=x*10+ch-'0', ch=getchar();
	return x*f;
}
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = (ll)1e18 + 3, base = rnd()%(mod-1)+1;
ll pw[100005];
void init(){
	pw[0]=1;
	for(ll i=1;i<=100000;i++) pw[i]=(__int128)pw[i-1]*base%mod;
}
struct Hash{
	ll sz, hsh;
	Hash(ll x=0){ sz=(x>0); hsh=x; }
	Hash(ll x,ll y){ sz=x, hsh=y; }
};
inline Hash operator+ (Hash A, Hash B){
	return Hash(A.sz+B.sz, ((__int128)A.hsh*pw[B.sz]+B.hsh)%mod);
}
inline Hash operator- (Hash A, Hash B){
	return Hash(A.sz-B.sz, (A.hsh+(__int128)(mod-B.hsh)*pw[A.sz-B.sz])%mod);
}
struct Data{
	ll n, a[100005];
	Hash tr[400005]; ll mx[400005];
	bool lf[400005];
	Hash merge(ll pos1, ll pos2){
		Hash ret;
		if(lf[pos2]) {
			if(mx[pos2] >= mx[pos1]) ret = Hash(mx[pos2]);
		}else{
			if(mx[pos1] > mx[pos2]) ret = merge(pos1, pos2<<1|1);
			else ret = merge(pos1, pos2<<1)+(tr[pos2]-tr[pos2<<1]);
		}
		return ret;
	}
	void pushup(ll pos){
		mx[pos] = max(mx[pos<<1], mx[pos<<1|1]);
		tr[pos] = tr[pos<<1] + merge(pos<<1, pos<<1|1);
	}
	void build(ll l,ll r,ll pos){
		if(l==r) {
			lf[pos]=1; tr[pos]=Hash(a[l]);
			mx[pos]=a[l]; return;
		}
		ll mid=(l+r)>>1;
		if(l<=mid) build(l,mid,pos<<1);
		if(mid<r)  build(mid+1,r,pos<<1|1);
		pushup(pos);
	}
	void update(ll l,ll r,ll x,ll v,ll pos){
		if(l==r){
			tr[pos]=Hash(v);
			mx[pos]=v; return;
		}
		ll mid=(l+r)>>1;
		if(x<=mid) update(l,mid,x,v,pos<<1);
		else update(mid+1,r,x,v,pos<<1|1);
		pushup(pos);
	}
	void init(){
		n=read();
		for(ll i=n;i>=1;i--) a[i]=read();
		build(1, n, 1);
	}
	void modify(ll x,ll v){
		update(1, n, n-x+1, v, 1);
	}
}d[2];

void procedure(){
	d[0].init(); d[1].init();
	ll q=read();
	while(q--){
		ll o=read()-1, x=read(), y=read();
		d[o].modify(x, y);
		puts(d[0].tr[1].hsh == d[1].tr[1].hsh ? "YES": "NO");
	}
}
int main(){
	#ifdef LOCAL
		assert(freopen("input.txt","r",stdin));
		assert(freopen("output.txt","w",stdout));
	#endif
	ll T=1;
	init();
	while(T--) procedure();
	return 0;
}

詳細信息

Test #1:

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

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: 0
Accepted
time: 13ms
memory: 23008kb

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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O
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 200000 tokens

Test #4:

score: 0
Accepted
time: 23ms
memory: 24984kb

input:

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

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
N...

result:

ok 200000 tokens

Test #5:

score: 0
Accepted
time: 16ms
memory: 23096kb

input:

4
1 1 2 2
1
1
200000
2 1 2
1 1 3
1 2 1
2 1 2
2 1 2
2 1 3
2 1 1
2 1 1
1 4 2
2 1 3
1 3 1
1 2 1
1 3 2
2 1 1
1 4 2
2 1 1
2 1 2
1 1 1
2 1 2
2 1 1
1 4 1
1 2 2
2 1 1
1 1 1
1 4 3
2 1 3
1 1 3
2 1 2
1 2 1
2 1 1
2 1 1
2 1 1
2 1 3
2 1 2
1 2 3
2 1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
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok 200000 tokens

Test #9:

score: -100
Wrong Answer
time: 18ms
memory: 20048kb

input:

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

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO...

result:

wrong answer 522nd words differ - expected: 'YES', found: 'NO'