QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#348548 | #8338. Quad Kingdoms Chess | ucup-team135# | WA | 28ms | 7876kb | C++20 | 3.3kb | 2024-03-09 19:27:55 | 2024-03-09 19:27:55 |
Judging History
answer
#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("avx","avx2","popcnt")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define app push_back
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__)
#else
#define debug(...)
#endif
#ifdef LOCAL
#define __int128 long long
#endif // LOCAL
#define bs bitset<65>
#define arr array<bitset<65>,65>
#define ull unsigned long long
mt19937_64 rnd;
const int maxn=1e5+5;
int a[maxn];int b[maxn];
int ha[maxn];
pair<int,int> t1[4*maxn];pair<int,int> t2[4*maxn];
int get1(int node,int tl,int tr,int ma)
{
if(tr-tl==1)
{
if(t1[node].first>=ma) {return t1[node].first;}
else {return 0;}
}
int tm=(tl+tr)/2;
if(t1[2*node+2].first>=ma) {return t1[node].second-t1[2*node+2].second+get1(2*node+2,tm,tr,ma);}
return get1(2*node+1,tl,tm,ma);
}
void upd1(int node,int tl,int tr)
{
t1[node].first=max(t1[2*node+1].first,t1[2*node+2].first);
int tm=(tl+tr)/2;
t1[node].second=t1[2*node+2].second+get1(2*node+1,tl,tm,t1[2*node+2].first);
}
void build1(int node,int tl,int tr)
{
if(tr-tl==1) {t1[node].first=a[tl];t1[node].second=ha[a[tl]];return;}
int tm=(tl+tr)/2;
build1(2*node+1,tl,tm);build1(2*node+2,tm,tr);
upd1(node,tl,tr);
}
void to1(int node,int tl,int tr,int pos,int val)
{
if(tl>pos || tr<=pos) return;
if(tr-tl==1) {t1[node].first=val;t1[node].second=ha[val];return;}
int tm=(tl+tr)/2;
to1(2*node+1,tl,tm,pos,val);to1(2*node+2,tm,tr,pos,val);
upd1(node,tl,tr);
}
int get2(int node,int tl,int tr,int ma)
{
if(tr-tl==1)
{
if(t2[node].first>=ma) {return t2[node].first;}
else {return 0;}
}
int tm=(tl+tr)/2;
if(t2[2*node+2].first>=ma) {return t2[node].second-t2[2*node+2].second+get2(2*node+2,tm,tr,ma);}
return get2(2*node+1,tl,tm,ma);
}
void upd2(int node,int tl,int tr)
{
t2[node].first=max(t2[2*node+1].first,t2[2*node+2].first);
int tm=(tl+tr)/2;
t2[node].second=t2[2*node+2].second+get2(2*node+1,tl,tm,t2[2*node+2].first);
}
void build2(int node,int tl,int tr)
{
if(tr-tl==1) {t2[node].first=b[tl];t2[node].second=ha[b[tl]];return;}
int tm=(tl+tr)/2;
build2(2*node+1,tl,tm);build2(2*node+2,tm,tr);
upd2(node,tl,tr);
}
void to2(int node,int tl,int tr,int pos,int val)
{
if(tl>pos || tr<=pos) return;
if(tr-tl==1) {t2[node].first=val;t2[node].second=ha[val];return;}
int tm=(tl+tr)/2;
to2(2*node+1,tl,tm,pos,val);to2(2*node+2,tm,tr,pos,val);
upd2(node,tl,tr);
}
int32_t main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
for(int i=0;i<maxn;++i) {ha[i]=rnd();}
int n1;cin>>n1;
for(int i=0;i<n1;++i) {cin>>a[i];}
int n2;cin>>n2;
for(int i=0;i<n2;++i) {cin>>b[i];}
build1(0,0,n1);build2(0,0,n2);
int q;cin>>q;
while(q--)
{
int typ;cin>>typ;
if(typ==1)
{
int pos,val;cin>>pos>>val;--pos;
to1(0,0,n1,pos,val);
}
else
{
int pos,val;cin>>pos>>val;--pos;
to2(0,0,n2,pos,val);
}
puts(t1[0].second==t2[0].second ? "YES" : "NO");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7788kb
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: 24ms
memory: 7852kb
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: 20ms
memory: 7876kb
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: 28ms
memory: 7792kb
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 1018th words differ - expected: 'NO', found: 'YES'