QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#347012 | #8338. Quad Kingdoms Chess | ucup-team1004# | WA | 29ms | 12228kb | C++14 | 2.2kb | 2024-03-09 09:58:54 | 2024-03-09 09:58:55 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e5+5,M=N*4+5,K=1000+5,mod=1e9+9,Mod=mod-1;const db eps=1e-9;const ll INF=2e18+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,m,A[N],B[N];ull val[N];
struct Tree{
#define ls v<<1
#define rs v<<1|1
int mx[M];ull f[M],sum[M];
ull find(int x,int l,int r,int v){
if(l==r) return mx[v]>=x?val[mx[v]]:0ull;
int m=l+r>>1;if(mx[rs]<x) return find(x,l,m,ls);
return f[v]+find(x,m+1,r,rs);
}
void up(int v,int l,int r){
mx[v]=max(mx[ls],mx[rs]);
f[v]=find(mx[rs],l,l+r>>1,ls);sum[v]=sum[rs]+f[v];
}
void build(int *A,int l,int r,int v=1){
if(l==r){mx[v]=A[l];f[v]=val[A[l]];return;}
int m=l+r>>1;build(A,l,m,ls);build(A,m+1,r,rs);up(v,l,r);
}
void modify(int x,int y,int l,int r,int v=1){
if(l==r){mx[v]=y;f[v]=val[y];return;}
int m=l+r>>1;x<=m?modify(x,y,l,m,ls):modify(x,y,m+1,r,rs);up(v,l,r);
}
}f1,f2;
void Solve(){
int i,j;mt19937_64 rnd(time(0));
for(i=1;i<=1e5;i++) val[i]=rnd();
scanf("%d",&n);
for(i=1;i<=n;i++) scanf("%d",&A[i]);f1.build(A,1,n);
scanf("%d",&m);
for(i=1;i<=m;i++) scanf("%d",&B[i]);f2.build(B,1,m);
int q;scanf("%d",&q);while(q--){
int op,x,y;scanf("%d%d%d",&op,&x,&y);
if(op==1) f1.modify(x,y,1,n);
else f2.modify(x,y,1,m);
puts(f1.sum[1]==f2.sum[1]?"YES":"NO");
// gdb(f1.sum[1],f2.sum[1]);
}
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 12156kb
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: 12228kb
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 YES YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES YES YES YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES 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 ...
result:
wrong answer 7th words differ - expected: 'NO', found: 'YES'