QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#75853 | #5302. Useful Algorithm | 275307894a | WA | 16ms | 118516kb | C++14 | 1.8kb | 2023-02-06 13:46:52 | 2023-02-06 13:46:56 |
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 PB push_back
using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned ll;
using namespace std;const int N=1e5+5,M=16+5,K=2e3+5,mod=924844033,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(time(0));
int n,m,q,W[N],C[N],D[N],P1[M],P2[M][N],Xi[M][N],T[M][N];ll x,y,z,LA;
ll GA(){LA=0;for(int i=1;i<=m;i++) LA=max(LA,1ll*P1[i]*W[i]);return LA;}
multiset<int> f[M][N];
void CG(int p,int x){
int i,j,B=(1<<p/2),S=1<<p;
Xi[p][x]=-INF;for(i=0;i<B;i++) Xi[p][x]=max(Xi[p][x],T[p][x*B+i]);
if(x>=S/B/2) x=S/B-1-x;
P2[p][x]=0;int Mx=-INF;for(i=1;i<B;i++) Mx=max(Mx,T[p][S-i-x*B]),P2[p][x]=max(P2[p][x],Mx+T[p][i+x*B]);
P1[p]=0;for(i=0;i<S/B/2;i++) P1[p]=max(P1[p],P2[p][i]);
Mx=-INF;
for(i=1;i<=S/B/2;i++)Mx=max(Mx,Xi[p][S/B-i]),P1[p]=max(P1[p],Mx+Xi[p][i]);
}
void Ins(int p,int x,int y){f[p][x].insert(y);T[p][x]=max(T[p][x],y);CG(p,x>>p/2);}
void Del(int p,int x,int y){f[p][x].erase(f[p][x].LB(y));T[p][x]=(f[p][x].empty()?-INF:*f[p][x].rbegin());CG(p,x>>p/2);}
int main(){
int i,j;scanf("%d%d%d",&n,&m,&q);for(i=1;i<=m;i++) scanf("%d",&W[i]);for(i=1;i<=n;i++) scanf("%d",&C[i]);for(i=1;i<=n;i++) scanf("%d",&D[i]);
Me(Xi,-0x3f);Me(T,-0x3f);for(j=1;j<=m;j++) for(i=1;i<=n;i++) Ins(j,C[i]&((1<<j)-1),D[i]);
printf("%lld\n",GA());
while(q--) {
scanf("%lld%lld%lld",&x,&y,&z);x^=LA;y^=LA;z^=LA;//cerr<<x<<' '<<y<<' '<<z<<'\n';
for(i=1;i<=m;i++) Del(i,C[x]&((1<<i)-1),D[x]);C[x]=y;D[x]=z;for(i=1;i<=m;i++) Ins(i,C[x]&((1<<i)-1),D[x]);
printf("%lld\n",GA());
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 16ms
memory: 118516kb
input:
5 3 3 1 2 4 0 0 1 2 7 10 10 5 3 1 27 24 29 20 16 19 13 8 9
output:
24 16 4 104
result:
wrong answer 3rd numbers differ - expected: '8', found: '4'