QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#95669#70. Bitaro, who Leaps through Timeeyiigjkn0 393ms61336kbC++142.2kb2023-04-11 11:46:272023-04-11 11:46:27

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-11 11:46:27]
  • 评测
  • 测评结果:0
  • 用时:393ms
  • 内存:61336kb
  • [2023-04-11 11:46:27]
  • 提交

answer

# include <bits/stdc++.h>
using namespace std;
using ll=long long;
struct Info
{
	bool tp;
	int x,y;
	ll z;
	Info(){}
	Info(bool t,int x,int y,ll z):tp(t),x(x),y(y),z(z){}
	Info operator+(const Info &t)const
	{
		if(tp)
		{
			if(t.tp)
			{
				if(x>t.y) return Info(0,x,t.y,x-t.y);
				else if(y<t.x) return Info(0,y,t.x,0);
				else return Info(1,max(x,t.x),min(y,t.y),0);
			}
			else
			{
				if(x>t.x) return Info(0,x,t.y,t.z+x-t.x);
				else if(y<t.x) return Info(0,x,t.y,t.z);
				else return t;
			}
		}
		else
		{
			if(t.tp)
			{
				if(t.x>y) return Info(0,x,t.x,z);
				else if(t.y<y) return Info(0,x,t.y,z+y-t.y);
				else return *this;
			}
			else return Info(0,x,t.y,z+t.z+max(y-t.x,0));
		}
	}
};
struct Seg
{
	int L[300010],R[300010],pos[300010];
	Info val[1100000];
	inline void pushup(int rt){val[rt]=val[rt*2]+val[rt*2+1];}
	void build(int rt,int l,int r)
	{
		if(l==r) return val[pos[l]=rt]=Info(1,L[l],R[l],0),void();
		int mid=(l+r)/2;
		build(rt*2,l,mid);
		build(rt*2+1,mid+1,r);
		pushup(rt);
	}
	void update(int x,int l,int r)
	{
		int u=pos[x];
		val[u]=Info(1,L[x]=l,R[x]=r,0);
		for(u/=2;u;u/=2) pushup(u);
	}
	Info query(int rt,int l,int r,int x,int y)
	{
		if(l>=x && r<=y) return val[rt];
		int mid=(l+r)/2;
		if(y<=mid) return query(rt*2,l,mid,x,y);
		else if(x>mid) return query(rt*2+1,mid+1,r,x,y);
		else return query(rt*2,l,mid,x,y)+query(rt*2+1,mid+1,r,x,y);
	}
}S1,S2;
int main()
{
	int n,m,l,r,op,x1,x2,t1,t2;
	cin>>n>>m;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&l,&r);
		S1.L[i]=l-i;S1.R[i]=r-i-1;
		S2.L[n-i]=l-(n-i);S2.R[n-i]=r-(n-i)-1;
	}
	S1.build(1,1,n-1);
	S2.build(1,1,n-1);
	while(m--)
	{
		scanf("%d",&op);
		if(op==1)
		{
			scanf("%d%d%d",&x1,&l,&r);
			S1.update(x1,l-x1,r-x1-1);
			S2.update(n-x1,l-(n-x1),r-(n-x1)-1);
		}
		else
		{
			scanf("%d%d%d%d",&x1,&t1,&x2,&t2);
			if(x1==x2) printf("%d\n",max(t1-t2,0));
			else if(x1<x2)
				printf("%lld\n",(Info(0,t1-x1,t1-x1,0)+S1.query(1,1,n-1,x1,x2-1)+Info(0,t2-x2,t2-x2,0)).z);
			else
				printf("%lld\n",(Info(0,t1-(n-x1+1),t1-(n-x1+1),0)+S2.query(1,1,n-1,n-x1+1,n-x2)+Info(0,t2-(n-x2+1),t2-(n-x2+1),0)).z);
		}
	}
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 11768kb

input:

20 18
115497790 671208773
326245299 528973482
100582193 437996818
89058008 771100620
768935396 842907844
187943946 997369106
455078418 542835554
536691525 970171971
564540350 570234421
657178750 753833933
386375484 979995375
389681484 772601117
634873482 897954663
87193815 139420775
259946990 394597...

output:

1319538667
286505553
517757980
315467463
561949186
106582836
0
304461403
191096499

result:

wrong answer 1st lines differ - expected: '1155445816', found: '1319538667'

Subtask #2:

score: 0
Wrong Answer

Test #42:

score: 0
Wrong Answer
time: 393ms
memory: 61336kb

input:

274318 300000
489215489 676617321
780126019 788585486
556851007 580284394
233372413 595198772
519202713 898223077
502895565 696411826
206200999 769856900
270143414 346344669
729812429 901771242
663771137 938786194
472985796 990513077
846601694 992055636
178982840 919444964
27052680 316046043
8183731...

output:

2962234413650
3994976691911
4259331993080
9476584538171
458865029718
4606231443866
6998124236611
11184507584416
608743926388
4704003334778
4049031875118
9128961498081
6366018491598
6958762695141
7232461353823
8112902400242
48279676334
1153175800636
2221399342965
5392459757779
460129516859
5409065454...

result:

wrong answer 1st lines differ - expected: '2849147975708', found: '2962234413650'

Subtask #3:

score: 0
Wrong Answer

Test #56:

score: 0
Wrong Answer
time: 374ms
memory: 61132kb

input:

270695 300000
513123795 772355425
210106247 394028231
276162603 911454418
105669187 977348162
173662950 272706156
152814457 669922258
344843731 523572913
316675910 752220119
109044474 322732409
555169512 652867118
622530606 779759913
153668285 339269709
150911093 937002300
186921016 855255616
118867...

output:

6811410316551
1195543465809
10154883762747
1161735953693
3745624851881
3477176120206
9054435961784
1263168979489
3118816717551
6261409755041
11369447749592
3564623732917
5863141086871
4451091013186
5101202450984
3011567656071
6119829571385
10561402497307
2475196842358
6097905272272
7974567408109
464...

result:

wrong answer 1st lines differ - expected: '6546523326977', found: '6811410316551'