![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Uva_数据和结构基础
文章平均质量分 78
Echo_咪
to feel rather than think.
展开
-
101 - The Blocks Problem
题目大意: 给你n个数字0~n-1 初始,数字i在位置i上 有如下四种操作: move a onto b:把a、b上面的所有数字移动回原来的位置,再把a移动到b上 move a over b: 把a上的数字移动回数字原来的位置,再把a移动到含有b的堆的上方 pile a onto b: 把b上的数字移动回原来的位置,把含有a的堆移动到b上(a原本上面的数字顺序不变) p原创 2016-08-19 06:39:38 · 206 阅读 · 0 评论 -
133 - The Dole Queued
原题大意: 编号1-N的N个人由1开始逆时针站成一个环。 从第一个人开始逆时针数K个人;再从第N个人开始顺时针数M个人,第K、M出队。 如果KM是同一个人,只出队一次。 从K逆时针下一个人、N顺时针下一个人开始,重复上述步骤。 直到队列为空。 思路: 关键字:数据结构 两种实现方式:双向链表 环形数组原创 2016-08-18 07:00:04 · 208 阅读 · 0 评论 -
657 - The die is cast
这题就是递归套用递归 先递归搜索骰子,如果在骰子里面发现了点,在对该点递归,同时更新点数。 代码如下: #include #include using namespace std; char pic[60][200]; int visit[60][200]; int cnt[100]; int col, row; //对骰子上的点递归 void dfs_dot(int x, i原创 2016-08-17 14:38:56 · 186 阅读 · 0 评论 -
784 - Maze Exploration
思路:从*所在的位置出发,dfs历遍所有与它联通的点并将其变为# dfs实现关键思路在于两点: 1.哪些点是与当前点联通的 2.dfs返回条件 代码如下: #include using namespace std; char maze[35][90]; int visit[35][90]; int r;//the row of maze void DFS(int ro原创 2016-08-17 13:29:36 · 210 阅读 · 0 评论 -
572 - Oil Deposits
一道基础的图的历遍的题。 思路是由一个v[][]标记当前位置是否被visit过,g[][]存储当前是否为pocket 每次DFS历遍一块deposit 主程序扫描g[][],没发现一块没有被visit过的pocket,就调用DFS以它为起点历遍它 代码如下: #include using namespace std; char g[110][110]; int vis[原创 2016-08-17 11:01:53 · 201 阅读 · 0 评论 -
10562 - Undraw the Trees
参考博客: http://blog.csdn.net/goomaple/article/details/7818170 自己的代码实现: #include using namespace std; char Tree[210][210]; void DFS(int r, int c) { cout << Tree[r][c]; //输出前导左括号 cout << "(原创 2016-08-17 08:00:58 · 189 阅读 · 0 评论 -
112 - Tree Summing
Background LISP was one of the earliest high-level programming languages and, with FORTRAN, is one of the oldest languages currently being used. Lists, which are the fundamental data structures in LI原创 2016-08-16 09:27:45 · 297 阅读 · 0 评论 -
699 - The Falling Leaves
原题 思路:先序历遍建树 从最左的一个结点p开始,输出第一堆 当p不是根节点的时候: p=p->parent cnt =p->e + p->left->right->e +p->right->left->e; 当p是根节点 当p->right!=NULL p=p->right cnt =p->e + p->left->right->e +p->rig原创 2016-09-06 10:09:32 · 245 阅读 · 0 评论