为什么能过?
查看原帖
为什么能过?
1127771
yekc2010楼主2024/7/3 09:41

同学的代码为什么能过,样例本地运行不对,用洛谷在线 IDE 能过样例?

#include <bits/stdc++.h> 
using namespace std;
int n;
char root,k;
struct node{
	char l,r;
}s[1500];
inline void qianxu(char x) {
	cout<<x;
	if(s[x].l!='*') qianxu(s[x].l);
	if(s[x].r!='*') qianxu(s[x].r);
	return;
}
signed main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	cin>>root>>s[root].l>>s[root].r;
	for(int i=2;i<=n;i++) {
		cin>>k;
		cin>>s[k].l>>s[k].r;
	}
	qianxu(root);
	return 0;
}

本地测试样例输出:

a bdicj bdicj
2024/7/3 09:41
加载中...