QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#707833 | #8338. Quad Kingdoms Chess | wyhao | WA | 32ms | 7968kb | C++14 | 2.3kb | 2024-11-03 17:45:06 | 2024-11-03 17:45:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=100005;
int n1,n2,m;
mt19937_64 rnd(114514);
int a[N],b[N];
map<int,ull>mp;
ull w1,w2;
int stk[N],tot;
bool in1[N],in2[N];
set<int>s1,s2;
ull HASH(int x){
// return 1<<x-1;
if(!mp[x]) mp[x]=rnd();
return mp[x];
}
vector<int> vec;
class SEG{
public:
int n;
struct node{
int x,y;
int mx;
ull hsh,lhsh;
}T[N<<2];
ull find(int p,int x){
if(T[p].mx < x) return 0;
if(T[p].x==T[p].y){
return T[p].hsh;
}
int mid=(T[p].x+T[p].y)>>1;
if(T[2*p+1].mx >= x) return T[p].lhsh ^ find(2*p+1,x);
else return find(2*p,x);
}
void up(int p){
T[p].mx=max(T[2*p].mx,T[2*p+1].mx);
T[p].lhsh = find(2*p,T[2*p+1].mx);
T[p].hsh = T[p].lhsh^T[2*p+1].hsh;
}
void init(int p,int l,int r,int *c){
T[p].x=l;T[p].y=r;
if(l<r){
int mid=(l+r)>>1;
init(2*p,l,mid,c);
init(2*p+1,mid+1,r,c);
up(p);
}else{
T[p].mx=c[l];
T[p].lhsh=0;
T[p].hsh=HASH(c[l]);
}
}
void change(int p,int l,int v){
if(T[p].x==T[p].y){
T[p].mx = v;
T[p].hsh= HASH(v);
return ;
}
int mid=(T[p].x+T[p].y)>>1;
if(l<=mid) change(2*p,l,v);
else change(2*p+1,l,v);
up(p);
}
void print(int p){
cout<<p<<" "<<T[p].x<<" "<<T[p].y<<":"<<T[p].hsh<<" "<<T[p].lhsh<<endl;
if(T[p].x==T[p].y) return ;
print(2*p);print(2*p+1);
}
}T1,T2;
int main(){
// freopen("ex.in","r",stdin);
scanf("%d",&n1);
for(int i=1;i<=n1;i++) scanf("%d",&a[i]);
T1.init(1,1,n1,a);
scanf("%d",&n2);
for(int i=1;i<=n2;i++) scanf("%d",&b[i]);
T2.init(1,1,n2,b);
scanf("%d",&m);
int opt,x,y;
// cout<<T1.T[1].hsh<<" "<<T2.T[1].hsh<<endl;
while(m--){
scanf("%d%d%d",&opt,&x,&y);
vec.clear();
if(opt==1){
T1.change(1,x,y);
// T1.print(1);
}else{
T2.change(1,x,y);
// T2.print(1);
}
if(T1.T[1].hsh == T2.T[1].hsh) puts("YES");
else puts("NO");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7828kb
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: -100
Wrong Answer
time: 32ms
memory: 7968kb
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 YES YES YES YES NO YES YES YES NO NO NO YES NO NO YES YES YES NO NO YES YES NO YES YES YES NO YES NO NO YES NO NO NO NO NO NO NO YES NO YES NO NO NO YE...
result:
wrong answer 48th words differ - expected: 'NO', found: 'YES'