QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#42865 | #4429. Gebyte's Grind | fecto_elfilis | WA | 4306ms | 191228kb | C++ | 2.2kb | 2022-08-04 15:37:25 | 2022-08-04 15:37:27 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2000010;
struct P {
ll a,b,v;
P (ll x=0,ll y=0) {
if (x==0) {a=b=v=0;}
else if (x==1) {a=b=y,v=0;}
else if (x==2) {a=y-1,v=y,b=1e18;}
else if (x==3) {a=0,b=v=y;}
}
}seg[N*4];
P operator + (P a,P b) {
P c;
if (a.v<=b.a) {
c.a=a.b+b.a-a.v;
c.b=c.a+b.b-b.a;
c.v=b.v;
} else {
c.a=a.a;
if (a.v<=b.b) {
c.b=a.b+b.b-a.v;
c.v=b.v;
} else {
c.b=a.b;
c.v=b.v+a.v-b.b;
}
}
return c;
}
ll read () {
ll res=0;
char c=getchar();
while (c<'0'||c>'9') {c=getchar();}
while (c>='0'&&c<='9') {
res=res*10-'0'+c;
c=getchar();
}
return res;
}
void write (ll x) {
if (x<=9) {putchar(x+'0');return;}
write(x/10);
putchar(x%10+'0');
}
ll t,n,q,h,x,y;
char s[10];
void buildt (int p,int l,int r) {
seg[p]=P();
if (l==r) {return;}
int mid=(l+r)>>1;
buildt(p<<1,l,mid),buildt((p<<1)|1,mid+1,r);
}
void modify (int p,int l,int r,int pos,P v) {
if (l==r) {seg[p]=v;return;}
int mid=(l+r)>>1;
if (pos<=mid) {modify(p<<1,l,mid,pos,v);}
else {modify((p<<1)|1,mid+1,r,pos,v);}
seg[p]=seg[p<<1]+seg[(p<<1)|1];
}
pair<ll,P> query (int p,int l,int r,int x,P nw) {
if (l==r) {
if ((nw+seg[p]).a>=h) {return make_pair(l-1,nw);}
else {return make_pair(l,nw+seg[p]);}
}
int mid=(l+r)>>1;
if (x>mid) {return query((p<<1)|1,mid+1,r,x,nw);}
else {
pair<ll,P> tmp=query(p<<1,l,mid,x,nw);
if (tmp.first<mid) {return tmp;}
P tmpp=tmp.second+seg[(p<<1)|1];
if (tmpp.a>=h) {return query((p<<1)|1,mid+1,r,x,tmp.second);}
else {return make_pair(r,tmpp);}
}
}
int main () {
t=read();
for (int ii=1;ii<=t;ii++) {
n=read();q=read(),h=read();
buildt(1,1,n);
for (int i=1;i<=n;i++) {
scanf("%s",s+1);
x=read();
modify(1,1,n,i,P(s[1]=='B'?1:(s[1]=='K'?2:3),x));
}
for (int i=1;i<=q;i++) {
scanf("%s",s+1);
x=read();
if (s[1]=='Z') {
scanf("%s",s+1);
y=read();
modify(1,1,n,x,P(s[1]=='B'?1:(s[1]=='K'?2:3),y));
} else {
ll res=query(1,1,n,x,P()).first;
if (res<x) {
putchar('-');
putchar('1');
putchar('\n');
} else {write(res);putchar('\n');}
}
}
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 4306ms
memory: 191228kb
input:
1 2000000 4000000 1000000000000 B 2982992025 B 1226542907 B 2299259203 B 1223702056 B 1407121251 B 340783317 B 1259091208 B 2101980047 B 2611543443 B 2010658889 B 4233714406 B 3112120167 B 2311876255 B 2789960428 B 3008572010 B 1 B 2464951378 B 1364240867 B 2829584762 B 2511437438 B 692948679 B 1113...
output:
833302 238155 1007466 1912727 1483707 996123 913464 595444 1956432 1007466 1224759 214012 1606540 541216 578117 1312500 2000000 647870 900696 1010723 1723225 1909185 765245 1875000 2000000 135066 2000000 423001 400637 188229 750000 1020950 31250 1007466 624537 2000000 2000000 856521 175916 1187336 1...
result:
wrong answer 10th lines differ - expected: '168794', found: '1007466'