uva 10562 undraw the trees(烂题) ——yhx
来源:互联网 发布:烟花算法程序 编辑:程序博客网 时间:2024/04/30 15:52
无需建树,递归即可。
为什么说是烂题呢?
1.pdf里的样例数据复制过来丢了空格,导致我调了很久都没有发现问题在哪。
2.如样例2所示,4个'-'下面却少一格。
3.空树,即只有'#'需要特殊处理。
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<string> 5 using namespace std; 6 char map[210][210]; 7 int m; 8 void dfs(int x,int p) 9 {10 int i,j,k,q,y,z;11 printf("%c(",map[x][p]);12 if (x<m&&map[x+1][p]=='|')13 {14 i=p;15 while (i>0&&map[x+2][i-1]=='-') i--;16 while (map[x+2][i]=='-'&&map[x+3][i])17 {18 if (map[x+3][i]!=' ') dfs(x+3,i);19 i++;20 }21 }22 printf(")");23 }24 int main()25 {26 int i,j,k,l,n,p,q,x,y,z;27 char c,c1,c2;28 scanf("%d%*c",&n);29 for (i=1;i<=n;i++)30 {31 m=0;32 while (1)33 {34 m++;35 gets(map[m]);36 if (map[m][0]=='#') break;37 }38 m--;39 if (!m)40 {41 printf("()\n");42 continue;43 }44 printf("(");45 for (j=0;;j++)46 if (map[1][j]!=' ')47 {48 dfs(1,j);49 break;50 }51 printf(")\n");52 }53 }
0 0
- uva 10562 undraw the trees(烂题) ——yhx
- uva 10562 undraw the trees(烂题) ——yhx
- 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 816 abbott's revenge ——yhx
- setTransformationMethod 的使用
- AutoLayout I
- uva 10305 ordering tasks(超级烂题)——yhx
- uva 10129 play on words——yhx
- uva 10562 undraw the trees(烂题) ——yhx
- 【Java】类执行过程
- uva 12171 sculpture (超级好题)——yhx
- iOS8下,cell分割线右移
- uva 1572 self-assembly ——yhx
- uva 1599 ideal path(好题)——yhx
- CTCC2016中国云计算技术大会参会感想
- 344. Reverse String (Iterator简介)
- uva 11853 paintball(好题)——yhx