Uva10562】的更多相关文章

  注意点: 空树情况处理. >= && buf[r+][i-]=='-') i--; #include<cstdio> #include<cstring> #include<iostream> #include<string> #include<algorithm> using namespace std; +; char buf[N][N]; int n; //递归遍历并且输出以字符buf[r][c]为根的树 void…
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1093 题目大意:有很多乌龟套在一起,你每次可以把任意一个乌龟移到栈的顶端,然后给你一个目标序列,问你 至少需要移动哪些乌龟,并按移动顺序输出这些乌龟的名字. 思路分析:想明白了以后就会发现,这道题很水,只需要把两个序列从末尾n-1开始比较,如果发现相同乌龟, 则原序列和目标序列同…
传送门: 1. UVA - 10562 2. Vjudge [看图写树]     将题目中给出的树改写为 括号表示法 即 (ROOT (SON1(...) (SON2(...)...(SONn(...))的表示方法,空树括号留空,例如: A | -------- B C D | | ----- - E F G # e | ---- f g # 上图有两棵树,'#'指该棵树如入完毕,将要表示为: (A(B()C(E()F())D(G()))) (e(f()g())) 分析:递归求解的经典题,类似于…
这个题过的好艰难,不过真的学到好多. 关于fgets的用法真的是精髓.!isspace(c)和c!=' '是有区别的. 其它的看代码吧 #include <iostream> #include <cstring> #include <string> #include <map> #include <set> #include <algorithm> #include <fstream> #include <cstdi…
上来一看感觉难以下手,仔细想想就是dfs啊!!!! #include <cstdio> #include<iostream> #include<iomanip> #include<cstring> #include<string> #include<queue> #include<algorithm> using namespace std; ; ][]; void dfs (int x,int y) {//x为第几行,y…
非常好的dfs题  有很多细节 关于‘ ’  ‘0’  ’\n‘  的处理  他们都属于isspace函数 其中 while(buf[x+2][i]=='-'&&buf[x+3][i]!='\0')  很重要    &&后面去掉的话会自动以\0为目标进行dfs  得到答案不止一行!!! 判断不是空格用!isspace() fgets用于读取行 在string不合适的时候  并且同样会读取换行符 if(n){ for(int i=0;i<strlen(buf[0]);i…
Professor Homer has been reported missing. We suspect that his recent research works might have had something to with this. But we really don't know much about what he was working on! The detectives tried to hack into his computer, but after hours of…
题目链接: https://cn.vjudge.net/problem/UVA-10562 Professor Homer has been reported missing. We suspect that his recent research works might have had something to with this. But we really don't know much about what he was working on! The detectives tried…
题目描述: 原题:https://vjudge.net/problem/UVA-10562 题目思路: 递归找结点 //自己的代码测试过了,一直WA,贴上紫书的代码 AC代码 #include<cstdio> #include<cctype> #include<cstring> using namespace std; + ; int n; char buf[maxn][maxn]; // 递归遍历并且输出以字符buf[r][c]为根的树 void dfs(int r,…