ACM篇:UVa 10562 -- Undraw the Trees
来源:互联网 发布:ios存储数据的方法 编辑:程序博客网 时间:2024/05/23 00:00
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <cstring>#include <sstream>#include <cmath>#include <cctype>using namespace std;const int MAX = 200;int n;char s[MAX+2][MAX+2];bool is_printable(char ch){ return !(ch == '|' || ch == '-' || ch == ' ' || ch == '#' || ch == '\0' || ch == '\n');}int read_tree(){ memset(s, 0, sizeof(s)); n = 0; while (gets(s[n]) && strcmp(s[n], "#")) n++;}void print_tree(int r, int lo, int hi){ putchar('('); for (int j = lo; j <= hi; j++) { if (is_printable(s[r][j])) { putchar(s[r][j]); if (s[r+1][j] == '|') { int begin = j; int end = j; while (begin && s[r+2][begin-1] == '-') begin--; while (s[r+2][end+1] == '-') end++; print_tree(r+3, begin, end); } else printf("()"); } } putchar(')'); }int main(){ int T; scanf("%d\n", &T); while (T-- > 0) { read_tree(); print_tree(0, 0, strlen(s[0])-1); putchar('\n'); } return 0;}
0 0
- ACM篇:UVa 10562 -- Undraw the Trees
- uva 10562 - Undraw the Trees
- uva 10562 - Undraw the Trees
- uva 10562 - Undraw the Trees
- UVa 10562 - Undraw the Trees
- UVA 10562 - Undraw the Trees
- UVA 10562 Undraw the Trees
- uva 10562 - Undraw the Trees
- uva 10562 - Undraw the Trees
- UVa 10562 - Undraw the Trees
- UVA 10562 Undraw the Trees
- UVA - 10562 Undraw the Trees
- uva-10562Undraw the Trees
- UVA 10562 - Undraw the Trees
- UVA - 10562 Undraw the Trees
- UVa 10562 - Undraw the Trees
- Uva - 10562 - Undraw the Trees
- uva 10562 Undraw the Trees
- Sql Server参数化查询之where in和like实现之xml和DataTable传参
- 13图像的复原
- navicat for mysql注册码,各种版本都有
- Reinforcement Learning
- 面向对象设计的SOLID原则
- ACM篇:UVa 10562 -- Undraw the Trees
- 取数字问题
- Powerdesiger 逆向工程 pdm
- 392. Is Subsequence
- fc-san相关
- 电脑快捷键的使用
- js 获取元素坐标 和鼠标点击坐标
- openvpn2.3.12安装与easy-rsa3的使用
- 24. Swap Nodes in Pairs