QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#354365 | #8338. Quad Kingdoms Chess | ship2077 | WA | 19ms | 23244kb | C++14 | 1.8kb | 2024-03-15 10:59:21 | 2024-03-15 10:59:22 |
Judging History
answer
#include<bits/stdc++.h>
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define fir first
#define sec second
using namespace std;
typedef unsigned long long ull;
constexpr int M=1e5+5;
int q,op,x,y,tmp,n[2];ull pw[M];
struct segtree{int mx;pair<ull,int>hash;}tr[2][M<<2];
pair<ull,int> operator +(pair<ull,int>a,pair<ull,int>b){
return {a.fir+b.fir*pw[a.sec],a.sec+b.sec};
}
pair<ull,int> operator -(pair<ull,int>a,pair<ull,int>b){
return {a.fir-b.fir*pw[a.sec-b.sec],a.sec-b.sec};
}
int read(){
int x=0;char ch=getchar();
while (!isdigit(ch)) ch=getchar();
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x;
}
pair<ull,int> calc(int l,int r,int x,int mx){
if (l==r) return tr[op][x].mx>=mx?(pair<ull,int>){mx,1}:(pair<ull,int>){0,0};
int mid=l+r>>1;
if (tr[op][rs(x)].mx<mx) return calc(l,mid,ls(x),mx);
return (tr[op][x].hash-tr[op][rs(x)].hash)+calc(mid+1,r,rs(x),mx);
}
void pushup(int x,int l,int r){
tr[op][x].mx=max(tr[op][ls(x)].mx,tr[op][rs(x)].mx);
tr[op][x].hash=calc(l,l+r>>1,ls(x),tr[op][rs(x)].mx)+tr[op][rs(x)].hash;
}
void build(int l,int r,int x){
if (l==r) return tmp=read(),tr[op][x].mx=tmp,tr[op][x].hash={tmp,1},void();
int mid=l+r>>1;build(l,mid,ls(x));build(mid+1,r,rs(x)); pushup(x,l,r);
}
void update(int u,int c,int l,int r,int x){
if (l==r) return tr[op][x].mx=c,tr[op][x].hash={c,1},void(); int mid=l+r>>1;
u<=mid?update(u,c,l,mid,ls(x)):update(u,c,mid+1,r,rs(x)); pushup(x,l,r);
}
int main(){
for (int i=pw[0]=1;i<M;i++) pw[i]=pw[i-1]*233;
n[0]=read();op=0;build(1,n[0],1);
n[1]=read();op=1;build(1,n[1],1);
q=read();while (q--){
op=read()-1;x=read();y=read();
update(x,y,1,n[op],1);
puts(tr[0][1].hash==tr[1][1].hash?"YES":"NO");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 23204kb
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: 19ms
memory: 23244kb
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:
NO NO NO NO YES YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES YES YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES YES 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 N...
result:
ok 200000 tokens
Test #3:
score: 0
Accepted
time: 15ms
memory: 23148kb
input:
6 2 1 1 2 1 2 1 1 200000 2 1 1 1 1 2 1 1 1 2 1 2 2 1 1 2 1 1 2 1 2 2 1 2 1 1 2 1 3 1 1 6 2 1 5 2 1 4 2 1 3 1 2 1 2 1 4 2 1 4 2 2 1 2 2 1 2 1 3 1 1 6 1 1 1 2 2 1 1 1 6 1 1 3 1 1 5 2 1 6 2 1 5 2 2 1 2 1 2 1 1 5 2 2 1 1 2 1 1 1 6 1 2 1 2 2 1 1 1 3 2 2 1 1 1 6 1 1 4 2 1 2 1 1 1 1 2 1 1 1 2 1 1 6 2 1 6 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 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 #4:
score: -100
Wrong Answer
time: 15ms
memory: 23132kb
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:
wrong answer 1110th words differ - expected: 'NO', found: 'YES'