QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#92588#21403. 文艺平衡树youngsystem#WA 0ms3724kbC++141.7kb2023-03-30 19:27:512023-03-30 19:27:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-30 19:27:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3724kb
  • [2023-03-30 19:27:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
int ch[100005][2],laz[100005],siz[100005],rnd[100005];
int rt;
void pushdown(int k)
{
	if(laz[k]!=0)return;
	if(ch[k][0]!=0)
	{
		laz[ch[k][0]]^=1;
		swap(ch[ch[k][0]][0],ch[ch[k][0]][1]);
	}
	if(ch[k][1]!=0)
	{
		laz[ch[k][1]]^=1;
		swap(ch[ch[k][1]][0],ch[ch[k][1]][1]);
	}
	laz[k]=0;
}
void split(int k,int x,int& tx,int& ty)
{
	if(k==0)
	{
		tx=0;
		ty=0;
		return;
	}
	pushdown(k);
	if(x<=siz[ch[k][0]])
	{
		ty=k;
		split(ch[k][0],x,tx,ch[k][0]);
		siz[k]=siz[ch[k][0]]+siz[ch[k][1]]+1;
	}
	else
	{
		tx=k;
		split(ch[k][1],x-siz[ch[k][0]]-1,ch[k][1],ty);
		siz[k]=siz[ch[k][0]]+siz[ch[k][1]]+1;
	}
}
int merge(int x,int y)
{
	if(x==0||y==0)return x+y;
	pushdown(x);
	pushdown(y);
	if(rnd[x]<rnd[y])
	{
		ch[x][1]=merge(ch[x][1],y);
		siz[x]=siz[ch[x][0]]+siz[ch[x][1]]+1;
		return x;
	}
	else
	{
		ch[y][0]=merge(x,ch[y][0]);
		siz[y]=siz[ch[y][0]]+siz[ch[y][1]]+1;
		return y;
	}
}
mt19937 ran(121296);
int qans[100005],cnt;
void bianli(int x)
{
	if(x==0)return;
	bianli(ch[x][0]);
	qans[++cnt]=x;
	bianli(ch[x][1]);
}
int main()
{
	int n,m,l,r,tx,ty,tz;
	n=read();
	m=read();
	for(int i=1;i<=n;i++)
	{
		siz[i]=i;
		ch[i][0]=ch[i][1]=0;
		laz[i]=0;
		rnd[i]=ran();
		rt=merge(rt,i);
	}
	for(int i=1;i<=m;i++)
	{
		l=read();
		r=read();
		split(rt,l-1,tx,ty);
		split(ty,r-l+1,ty,tz);
		laz[ty]^=1;
		swap(ch[ty][0],ch[ty][1]);
		rt=merge(merge(tx,ty),tz);
	}
	bianli(rt);
	for(int i=1;i<=n;i++)printf("%d ",qans[i]);
	printf("\n");
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3724kb

input:

30 5
7 26
7 18
5 9
4 15
3 15

output:

1 4 7 8 17 13 19 9 5 3 11 15 18 20 14 21 12 6 10 16 2 22 28 25 24 23 26 30 27 29 

result:

wrong answer 1st lines differ - expected: '1 2 4 17 16 15 6 5 18 19 20 21...4 13 12 11 10 9 8 7 27 28 29 30', found: '1 4 7 8 17 13 19 9 5 3 11 15 1...6 2 22 28 25 24 23 26 30 27 29 '