problem

一直忘记给这个题写题解了。

这题挺水的吧。

挺后悔当时没写出来。

#ifdef Dubug

#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long LL ;
inline LL In() { LL res(0),f(1); register char c ;
while(isspace(c=getchar())) ; c == '-'? f = -1 , c = getchar() : 0 ;
while(res = (res << 1) + (res << 3) + (c & 15) , isdigit(c=getchar())) ;
return res * f ;
} int n ;
const int N = 1e6 + 5 ;
int a[N] ;
int Left[N] , Right[N] ;
int sum = 1 ; inline bool dfs(int x,int y) {//搜索能否有对称。
if(x == -1 and y == -1) return 1 ;
if(x == -1 or y == -1 or a[x] != a[y]) return 0 ;
sum += 2 ;
return (dfs(Left[x],Right[y]) and dfs(Left[y],Right[x])) ;
} signed main() {
n = In() ;
for(register int i=1;i<=n;i++) a[i] = In() ;
for(register int i=1;i<=n;i++) Left[i] = In() , Right[i] = In() ;
int ans = -0x7f ;
for(register int i=1;i<=n;i++) {//每个枚举一遍。n个节点。
sum = 1 ;//初始化
if(dfs(Left[i],Right[i])) ans = max(ans,sum) ;//如果有对称 那么更新ans
}
cout << ans << endl ;
return 0 ;
}

最新文章

  1. python文件操作
  2. windows系统激活-使用微软官方公布的kms client setup key安装或安装后使用slmgr导入
  3. PowerDesigner导出建表sql脚本
  4. 九幽2015年Q3 WP市场份额细分报告
  5. Hibernate设置派生属性(formula)
  6. Linux磁盘分区实战案例
  7. 网页在Safari快速滚动和回弹的原理: -webkit-overflow-scrolling : touch;的实现
  8. SQL SERVER大话存储结构(4)_复合索引与包含索引
  9. slf4j-logback 日志以json格式导入ELK
  10. 内存管理单元--MMU
  11. ajax跨域例子
  12. Java-接口(interface)
  13. 函数防抖 debounce
  14. Python中【__all__】的用法
  15. Qsys 设计流程---Qsys System Design Tutorial
  16. mysql中参数--init-file的作用是什么呢?
  17. 迷你MVVM框架 avalonjs 1.2.4发布
  18. Oracle 表空间、段、区和块简述
  19. QT学习笔记2:QT中常用函数
  20. POJ 3057 Evacuation 二分+最大流

热门文章

  1. Python selenium chrome打包exe后禁用控制台输出滚动日志
  2. Leetcode 133.克隆图
  3. MaxScale初探
  4. 转载 - PowerDesigner(CDM—PDM—SQL脚本的转换流程)
  5. 用API中的raf复制文件图片等及系统找不到指定的文件的解决办法
  6. AbstractList 重写 equals() 方法
  7. 10、Java并发性和多线程-线程安全与不可变性
  8. Java数据库连接池研究
  9. 【CV论文阅读】Dynamic image networks for action recognition
  10. ZOJ 3201