2015安徽省赛 J.镜像树

http://xcacm.hfut.edu.cn/problem.php?id=1214

乱搞题

数组+结构体 递归遍历

#include<iostream>
#include<cstdio>
#include<cstring>
#define within(x,a,b) ((unsigned)((x)-(a))<=((b)-(a)))
using namespace std;
int readint(int *p)
{
int ch;
while(!within(ch=getchar(),'',''))
if(ch == EOF) return EOF;
int rslt = ;
do
rslt=rslt*+(ch-'');
while(within(ch=getchar(),'',''));
*p = rslt;
return ;
}
int n,just=;
struct donser
{
int data;
int left;
int right;
};
struct donser d[]; void judge(int i,int j)
{
if(d[i].data==&&d[j].data==) return;
if(d[i].data!=d[j].data){just=;return;}
int x,y;
x=d[i].left;
y=d[j].right;
judge(x,y);
x=d[i].right;
y=d[j].left;
judge(x,y);
return;
} int main()
{
int i,k;
readint(&k);
while(k--)
{
readint(&n);
int ro,le,re;
for(i=;i<=n;i++)
{
readint(&ro);
readint(&le);
readint(&re);
d[ro].left=le;
d[ro].right=re;
}
for(i=;i<=n;i++)
{
readint(&ro);
d[i].data=ro;
}
judge(,);
if(just==){just=;cout<<"No"<<endl;continue;}
cout<<"Yes"<<endl;
memset(d,,sizeof(d));
}
return ;
}
上一篇:Android中,利用Intent传递对象值


下一篇:3500常用汉字与标点符号(已排除不支持GB2312的)