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 ;
}
2015安徽省赛 J.镜像树的更多相关文章
- 2015安徽省赛 G.你来擒孟获
http://xcacm.hfut.edu.cn/problem.php?id=1211 SPFA模板题目 最短路变种,从起点终点各找一次最短路相加 #include<iostream> ...
- 2015安徽省赛 H.数7
http://xcacm.hfut.edu.cn/problem.php?id=1212 模拟大发 #include<iostream> #include<cstdio> #i ...
- 2015安徽省赛 I.梯田
http://xcacm.hfut.edu.cn/problem.php?id=1213 set + 搜索 姐姐是用搜索+二分做的,效率要高很多 #include<iostream> #i ...
- 2015安徽省赛 F.多重部分和问题
题目描述 有n种不同大小的数字,每种各个.判断是否可以从这些数字之中选出若干使它们的和恰好为K. 输入 首先是一个正整数T(1<=T<=100) 接下来是T组数据 每组数据第一行是一个正整 ...
- 2015安徽省赛 D.锐雯上单不给就送
题目描述 <英雄联盟>(简称LOL)是由美国Riot Games开发,腾讯游戏运营的英雄对战网游.<英雄联盟>除了即时战略.团队作战外,还拥有特色的英雄.自动匹配的战网平台,包 ...
- 2015安徽省赛 C.LU的困惑
题目描述 Master LU 非常喜欢数学,现在有个问题:在二维空间上一共有n个点,LU每连接两个点,就会确定一条直线,对应有一个斜率.现在LU把平面内所有点中任意两点连线,得到的斜率放入一个集合中( ...
- 2015安徽省赛 B.求和
题目描述 对于正整数n,k,我们定义这样一个函数f,它满足如下规律 现在给出n和k,你的任务就是要计算f(n,k)的值. 输入 首先是一个整数T,表示有T组数据 接下来每组数据是n和k(1<=n ...
- 2015安徽省赛 A.First Blood
题目描述 盖伦是个小学一年级的学生,在一次数学课的时候,老师给他们出了一个难题: 老师给了一个正整数 n,需要在不大于n的范围内选择三个正整数(可以是相同的),使它们三个的最小公倍数尽可能的大.盖伦很 ...
- 镜像树(dfs)
1214: J.镜像树 时间限制: 1 Sec 内存限制: 64 MB提交: 18 解决: 7 标签提交统计讨论版 题目描述 一棵二叉树,若其与自己的镜像完全相同,就称其为镜像树(即这棵二叉树关于 ...
随机推荐
- ef6 缓存的问题没有了
public static void Main(string[] args) { PMTestEntities db = new PMTestEntities(); var users = db.Us ...
- telnet连接ip
win7 telnet命令无法开启的解决方案(不是内部命令或外部命令) 出处:西西整理 作者:西西 日期:2012-12-21 14:22:06 [大 中 小] 评论: 0 | 我要发表看法 如果你想 ...
- Linux学习笔记<四>
<1>shutdown -h now 立刻进行关机 shutdown -r now/reboor 现在重新启动计算机 <2>尽量避免用root用户登陆,用普通用户登陆后换成ro ...
- Unity3D Multi-Compile Shader
http://www.martinpalko.com/muli-compile-unity/ http://forum.unity3d.com/threads/tutorial-shade-more- ...
- Only one statement is allowed per batch. A batch separator, such as 'GO', might be required between statements.
When I added the file in VS I forgot to set Build Action = None from the file properties.
- Autofac IContainer 测试
using Autofac; using System; using System.Collections.Generic; using System.Linq; using System.Text; ...
- CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)
CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL) 一.准备篇: /etc/init.d/iptables stop #关闭防火墙 关闭SELINUX vi /etc/sel ...
- 使用Java练习算法常用的基本操作
一.使用Java练习算法常常需要使用控制台的数据输入和输出,下面记录一下基本的使用方法: 基本用法 import java.util.*; public class Main { public sta ...
- jquery判断checkbox是否选中及改变checkbox状态
转自:http://blog.csdn.net/limingchuan123456789/article/details/11499665 jquery判断checked的三种方法:.attr('ch ...
- 11个Visual Studio代码性能分析工具
软件开发中的性能优化对程序员来说是一个非常重要的问题.一个小问题可能成为一个大的系统的瓶颈.但是对于程序员来说,通过自身去优化代码是十分困难的.幸运的是,有一些非常棒的工具可以帮助程序员进行代码分析和 ...