问个问题
查看原帖
问个问题
454986
_Collapse_楼主2024/8/16 16:48

除了dfs的输出部分其他全部一样,为什么用快输的不对

WA:

inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	int stk[35],top=0;
	stk[top++]=x%10,x/=10;
	while(x) stk[top++]=x%10,x/=10;
	while(top) putchar(stk[--top]+'0');
	return;
}
inline void dfs(int p)
{
	push_down(p);
	if(t[p].lson) dfs(t[p].lson);
	write(t[p].val),putchar('\0');
	if(t[p].rson) dfs(t[p].rson);
	return;
}

AC:

inline void dfs(int p)
{
	push_down(p);
	if(t[p].lson) dfs(t[p].lson);
	printf("%d ",t[p].val);
	if(t[p].rson) dfs(t[p].rson);
	return;
}
2024/8/16 16:48
加载中...