QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#354346#8338. Quad Kingdoms Chessship2077WA 14ms23096kbC++141.8kb2024-03-15 10:35:332024-03-15 10:35:35

Judging History

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

  • [2024-03-15 10:35:35]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:23096kb
  • [2024-03-15 10:35:33]
  • 提交

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*pw[b.sec]+b.fir,a.sec+b.sec};
}
pair<ull,int> operator -(pair<ull,int>a,pair<ull,int>b){
    return {a.fir-b.fir,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),tr[op][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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 11ms
memory: 23096kb

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: 3ms
memory: 23088kb

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: 14ms
memory: 23088kb

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
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
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 27th words differ - expected: 'YES', found: 'NO'