QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#707840 | #8338. Quad Kingdoms Chess | wyhao | WA | 29ms | 8780kb | C++14 | 2.3kb | 2024-11-03 17:47:24 | 2024-11-03 17:47:24 |
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(time(0));
int a[N],b[N];
ull mp[N];
ull w1,w2;
int stk[N],tot;
bool in1[N],in2[N];
set<int>s1,s2;
ull HASH(int x){
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);
for(int i=1;i<N;i++) mp[i]=rnd();
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;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 7996kb
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: 29ms
memory: 8780kb
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'