HDU
来源:互联网 发布:皇室战争数据 编辑:程序博客网 时间:2024/06/09 22:13
题目大意:
dingyeye喜欢和你玩石子游戏。dingyeye有一棵
解题思路:
设根节点的深度为
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <vector>using namespace std;const int maxn = 1e5 + 10;int n, a[maxn], judge;vector<int> v[maxn];void dfs(int u, int deep) { if (deep & 1) judge ^= a[u]; for (int i = 0; i < v[u].size(); i++) { dfs(v[u][i], deep + 1); }}int main(){ int T; scanf("%d", &T); while (T--) { scanf("%d", &n); judge = 0; for (int i = 0; i <= n; i++) v[i].clear(); for (int i = 1; i < n; i++) { int temp; scanf("%d", &temp); v[temp].push_back(i); } for (int i = 0; i < n; i++) scanf("%d", &a[i]); dfs(0, 0); puts(judge != 0 ? "win" : "lose"); } return 0;}
阅读全文
1 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- 暑期集训test5
- “动次打次!”——用Web技术实现移动监测
- 基于HDFS的实时计算和wordcount程序
- php iconv实现编码转换
- 积分行业内幕、信用卡积分规则!你知道多少?
- HDU
- 设计模式之代理模式and装饰者模式
- MySQL复制表结构和内容到另一张表中的SQL语句
- Apache笔记
- 通过腾讯shuffle部署对shuffle过程进行详解
- Listener学习笔记-- day01 监听器的使用
- 怎么转载CSDN博客
- Caffe tutorial 之 前向与反向传播
- 加密芯片——摘要算法特点与应用注意事项