QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#412931#8672. 排队g1ove0 0ms0kbC++142.2kb2024-05-16 21:48:252024-05-16 21:48:26

Judging History

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

  • [2024-05-16 21:48:26]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-05-16 21:48:25]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define N 1000005
using namespace std;
const int inf=1e6+8;
int n,m;
int l[N],r[N];
int stk[N],top;
struct segtree{
	int tr[N*4],lz[N*4],p[N*4];
	void Pushup(int x)
	{
		if(tr[x*2]<=tr[x*2+1]) tr[x]=tr[x*2],p[x]=p[x*2];
		else tr[x]=tr[x*2+1],p[x]=p[x*2+1];
	} 
	void Pushdown(int x)
	{
		if(!lz[x]) return;
		tr[x*2]+=lz[x];
		tr[x*2+1]+=lz[x];
		lz[x*2]+=lz[x];
		lz[x*2+1]+=lz[x];
		lz[x]=0;
	}
	void modify(int l,int r,int L,int R,int x,int v)
	{
		if(l>R||r<L) return;
		if(l>=L&&r<=R)
		{
			tr[x]+=v;
			lz[x]+=v;
			if(l==r) p[x]=l;
			return;
		}
		int mid=(l+r)/2;
		Pushdown(x);
		modify(l,mid,L,R,x*2,v);
		modify(mid+1,r,L,R,x*2+1,v);
		Pushup(x);
	}
	int query(int l,int r,int p,int x)
	{
		if(l==r) return tr[x];
		int mid=(l+r)/2;
		Pushdown(x);
		if(p<=mid) return query(l,mid,p,x*2);
		else return query(mid+1,r,p,x*2+1);
	}
}tr1,tr2,tr3;
int ans[N];
struct node{
	int p,id;
};
vector<node> E[N];
int main()
{
	freopen("m.txt","w",stdout);
	scanf("%d",&n);
//	scanf("%d%d",&n,&m);
	srand(17);
	for(int i=1;i<=n;i++) 
	{
		l[i]=rand()%10,r[i]=rand()%10;
		if(l[i]>r[i]) swap(l[i],r[i]);
	}
//	for(int i=1;i<=n;i++)
//		scanf("%d%d",&l[i],&r[i]);
	tr1.modify(1,n,1,n,1,inf);
	tr2.modify(1,n,1,n,1,inf);
//	for(int i=1;i<=m;i++)
//	{
//		int l,r;
//		scanf("%d%d",&l,&r);
//		E[l].push_back((node){r,i});
//	}
	for(int i=n;i>=1;i--)
	{
		tr1.modify(1,n,i,i,1,l[i]-inf);
		tr2.modify(1,n,i,i,1,r[i]+1-inf);
		while(1)
		{
			int l1=tr1.p[1],l2=tr2.p[1];
			if(tr1.tr[1]>0&&tr2.tr[1]>0) break;
			if(tr1.tr[1]>0) l1=inf;
			if(tr2.tr[1]>0) l2=inf;
			if(l1<l2)
			{
				tr1.modify(1,n,l1,l1,1,inf);
				tr1.modify(1,n,l1+1,n,1,-1);
				tr2.modify(1,n,l1+1,n,1,-1);
				tr3.modify(1,n,l1,n,1,1);
			}
			else
			{
				tr2.modify(1,n,l2,l2,1,inf);
				tr1.modify(1,n,l2+1,n,1,1);
				tr2.modify(1,n,l2+1,n,1,1);
				tr3.modify(1,n,l2,n,1,-1);
			}
		}
		for(int j=i;j<=n;j++) printf("%d ",tr3.query(1,n,j,1));
		printf("\n");
		for(auto u:E[i]) ans[u.id]=tr3.query(1,n,u.p,1);
	}
//	for(int i=1;i<=m;i++) printf("%d\n",ans[i]);
	return 0;
}

详细

Subtask #1:

score: 0
Dangerous Syscalls

Test #1:

score: 0
Dangerous Syscalls

input:

3 3
0 0
1 2
0 2
1 1
1 3
2 3

output:


result:


Subtask #2:

score: 0
Dangerous Syscalls

Test #12:

score: 0
Dangerous Syscalls

input:

200000 200000
3 6
3 3
6 10
1 7
2 7
6 9
4 6
3 4
0 8
0 6
3 5
3 4
1 8
7 8
4 5
0 3
1 5
2 9
1 2
1 2
3 4
5 7
6 10
3 9
4 7
1 6
2 6
1 7
2 5
1 7
6 8
1 1
0 7
7 8
0 9
1 7
3 8
3 7
1 2
4 8
5 6
0 6
5 6
2 7
2 6
0 6
0 6
1 7
2 5
0 3
0 3
7 10
3 8
0 2
3 4
3 7
4 9
0 6
4 7
2 6
8 10
2 10
4 10
3 3
2 6
4 5
3 9
1 8
1 2
2 9
...

output:


result:


Subtask #3:

score: 0
Dangerous Syscalls

Test #22:

score: 0
Dangerous Syscalls

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 0
0 9
0 10
0 0
0 0
0 13
0 14
0 0
0 16
0 17
0 18
0 19
0 0
0 21
0 22
0 23
0 0
0 0
0 0
0 0
0 28
0 0
0 30
0 31
0 32
0 33
0 34
0 35
0 0
0 0
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 0
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 0
0 59
0 60
0 0
0 0
...

output:


result:


Subtask #4:

score: 0
Dangerous Syscalls

Test #32:

score: 0
Dangerous Syscalls

input:

200000 200000
0 200000
1 200000
1 200000
0 200000
0 200000
1 200000
1 200000
1 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
0 200000
0 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
1 200000
1 200000
1 200000
1 200000
0 200000
0 200000
1 200000
2 200000
1 200000
2 20000...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%