QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#42869#4429. Gebyte's Grindfecto_elfilisWA 4276ms191352kbC++2.4kb2022-08-04 16:08:272022-08-04 16:08:29

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-04 16:08:29]
  • 评测
  • 测评结果:WA
  • 用时:4276ms
  • 内存:191352kb
  • [2022-08-04 16:08:27]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2000010;

int cntt;

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 (cntt==10&&r>=168794) printf("%d   %d  %d  %d   %lld   %lld  %lld  %lld\n",p,l,mid,r,tmp.first,
		tmp.second.a,tmp.second.b,tmp.second.v);
		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 {
				cntt++;
				ll res=query(1,1,n,x,P()).first;
				continue;
				if (res<x) {
					putchar('-');
					putchar('1');
					putchar('\n');
				} else {write(res);putchar('\n');}
			}
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 4276ms
memory: 191352kb

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:

138   156251  164063  171875   164063   3823310308  2000002535532956141  971750892626
69   156251  171875  187500   171875   3823310308  5553267253333363880  235230670377
17   125001  187500  250000   187500   -8340204463599563844  -7340203733594139499  7446739769463320657
4   1  250000  500000   25...

result:

wrong answer 1st lines differ - expected: '833302', found: '138   156251  164063  171875  ...00002535532956141  971750892626'