UESTC 2016 Summer Training #1 J - Objects Panel (A) 按条件遍历树
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long LL; char s[];
vector<int> num[]; void dfs(int u, int k)
{
int d = num[u].size(), v;
for(int i = ; i < d; i++){
v = num[u][i];
for(int j = ; j < k; j++) printf(" ");
if(num[v].size()){
if(s[v] == '-'){printf("- object%d\n", v); dfs(v, k+);}
else printf("+ object%d\n", v);
}
else printf(" object%d\n", v);
/*
if(s[v] == '-'){
if(num[v].size()) {printf("- object%d\n", v); dfs(v, k+1);}
else printf(" object%d\n", v);
}
else if(s[v] == '+') printf("+ object%d\n", v);
*/ }
} int main()
{
#ifdef LOCAL
freopen("a.txt", "r", stdin);
//freopen("b.txt", "w", stdout);
int T = ;
while(T--){
#endif // LOCAL
int n, k, val;
scanf("%d", &n);
for(int i = ; i <= n; i++){
getchar();
scanf("%c", &s[i]);
scanf("%d", &k);
while(k--){
scanf("%d", &val);
num[i].push_back(val);
}
} if(n == ) {printf(" project\n");}
else{
if(s[] == '-'){
printf("- project\n");
dfs(, );
}
else printf("+ project\n");
} #ifdef LOCAL
printf("\n");
}
#endif // LOCAL
return ;
}
UESTC 2016 Summer Training #1 J - Objects Panel (A) 按条件遍历树的更多相关文章
- UESTC 2016 Summer Training #1 Div.2
最近意志力好飘摇..不知道坚不坚持得下去.. 这么弱还瞎纠结...可以滚了.. 水题都不会做.. LCS (A) 水 LCS (B) 没有看题 Gym 100989C 水 1D Cafeteria ( ...
- UESTC 2016 Summer Training #6 Div.2
我好菜啊.. UVALive 6434 给出 n 个数,分成m组,每组的价值为最大值减去最小值,每组至少有1个,如果这一组只有一个数的话,价值为0 问 最小的价值是多少 dp[i][j] 表示将 前 ...
- The Solution of UESTC 2016 Summer Training #1 Div.2 Problem C
Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/C Description standard input/output After ...
- The Solution of UESTC 2016 Summer Training #1 Div.2 Problem B
Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/B Description standard input/output Althou ...
- The Solution of UESTC 2016 Summer Training #1 Div.2 Problem A
Link http://acm.hust.edu.cn/vjudge/contest/121539#problem/A Description standard input/output Haneen ...
- 2016 Multi-University Training Contest 1 J.Subway
Subway Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Su ...
- 2016 Multi-University Training Contest 1 G. Rigid Frameworks
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2016 Multi-University Training Contest 1
8/11 2016 Multi-University Training Contest 1 官方题解 老年选手历险记 最小生成树+线性期望 A Abandoned country(BH) 题意: 1. ...
- 2016 Multi-University Training Contest 2
8/13 2016 Multi-University Training Contest 2官方题解 数学 A Acperience(CYD)题意: 给定一个向量,求他减去一个 α(>=0)乘以 ...
随机推荐
- windows7-tomcat配置
1.下载 2.解压缩 3.配置环境变量 (1)计算机属性--高级系统配置--高级--环境变量--系统变量--新建 (2)CATALINA_HOME 如:C:\apache-tomcat-7.0.73 ...
- awk工具的基本用法
awk文本过滤的基本用法 1)基本操作方法 格式:awk [选项] '[条件]{指令}' 文件 其中,print 是最常用的编辑指令:若有多条编辑指令,可用分号分隔. Awk过滤数据时支持仅打印某一列 ...
- upload上传通关游戏
第一关:后缀名限制,抓包改一下后缀. 前端脚本检测文件扩展名.当客户端选择文件点击上传的时候,客户端还没有向服务器发送任何消 息,前端的 js 脚本就对文件的扩展名进行检测来判断是否是可以上传的类型 ...
- 关于Angular+ngx-perfect-scrollbar自定义各大浏览器滚动条样式的解决方法
资料: http://manos.malihu.gr/jquery-custom-content-scroller/ (此项是结合Jquery使用的,在此并未采用) https://www.npmj ...
- new , delete常见用法和与malloc,free比较
new/delete是C++的运算符.malloc与free是C++/C语言的标准库函数,new/delete只能在C++中使用,malloc与free在C与C++中都能够使用,它们都可用于申请动态内 ...
- [TCP/IP] 滑动窗口
什么是滑动窗口? 滑动窗口机制是TCP协议的一种流量控制和防拥塞的机制. 滑动窗口的工作原理? 简单来讲,就是接收方和发送方分别保留一块缓冲区,作为接收和发送数据来使用,发送数据过程中,如果发送方发的 ...
- SpringBoot传参方式
地址传参 1.创建一个Action类 package com.lion.action; import org.springframework.stereotype.Controller; import ...
- C - Co-prime
Given a number N, you are asked to count the number of integers between A and B inclusive which are ...
- B - How many integers can you find
Now you get a number N, and a M-integers set, you should find out how many integers which are smal ...
- hyper-v虚拟机centos7网络配置
原文地址:https://jingyan.baidu.com/article/91f5db1b0279bd1c7e05e377.html hyper-v安装了centos7之后并不能上网,这里简单介绍 ...