
数据结构
wjjayo
这个作者很懒,什么都没留下…
展开
-
uva 657
<br />题目大致是说要你在一个大图里搜四连块(每个四连块表示一个色子面)的个数,在每个四连块里搜色子的点数,点数只能是1到6之间的数.......<br />#include <iostream>#include <cstring>using namespace std ;const int maxn = 50 + 10 ;char map[maxn][maxn] ;bool visit[maxn][maxn] ;int ans[maxn * maxn] ;int原创 2010-08-08 09:49:00 · 1242 阅读 · 2 评论 -
uva 10596
<br />这道题据说有问题,但是是欧拉回路一类的问题是确定无疑的<br />#include <iostream>#include <cstring>using namespace std ;const int maxn = 200 + 10 ;bool G[maxn][maxn] ;bool visit[maxn] ;int d[maxn] ;int cnt ;void init(){ memset( G , false , sizeof( G原创 2010-08-18 13:32:00 · 880 阅读 · 0 评论 -
uva 10004
<br />一次遍历,直接得出结果,厉害!<br />#include <iostream>#include <cstring>#include <queue>using namespace std ;const int maxn = 200 + 10 ;int nn , ne ;bool G[maxn][maxn] ;int c[maxn] ;void init(){ memset( G , false , sizeof( G ) ) ;原创 2010-08-14 14:26:00 · 520 阅读 · 0 评论 -
uva 10305
<br />基本的拓扑排序<br />#include <iostream>#include <cstring>using namespace std ;const int maxn = 100 + 10 ;bool G[maxn][maxn] ;int c[maxn] ;int arr[maxn] ;int cnt ;bool dfs( int u , int n ){ c[u] = -1 ; for( int v = 1 ; v <原创 2010-08-14 14:23:00 · 1497 阅读 · 0 评论 -
uva 10047
哈哈,错了错了,全错了.......... 做这道题给我的启发不少,首先,我对visit数组的认识有了一个新的认识,以前一直认为它仅仅是标记一下到没到过一个占,现在才知道理解错了,以前仅仅是巧合.......我是水货......呵呵,不过现在知道了,它是用来表示某个状态是否出现过,也就是说同一个状态不能出现两次,明白了这点,就知道visit应该是个四维数组(在一个格子里,坐标,方向,颜色)........明白这点,以后的就和一以前的差不多了 但是,需要注意的是优先队列的使用,非常关键,我们需要每次都用最原创 2010-08-13 15:26:00 · 1690 阅读 · 1 评论 -
uva 705
<br />这道题是非常有意思的一道题,平常我们只在横竖之间徘徊,所以乍一看还真有些不会做,但事实上是真不会做,脑子一天总有些稀奇古怪的想法,但是当真正用到它们的时候,一个个全跑光了,太不仗义了,所以我去搜了下,发现竟然有人把一个点分成了四个,然后搜索。后来发现有更牛的,把一个点分成九个!这个太帅了,而且符合我的思想,所以就用它了。不管怎么样,他们都用到了一个思想,那就是把图给放大了,然后这些陌生的图就变为我们经常见到的东西。也就是说,不会斜的,我们可以把它给变直了,甚至可以把图给变成0和1这个总该会了吧?原创 2010-08-10 18:09:00 · 1174 阅读 · 0 评论 -
uva 439
跳马问题,只要把方向数组给写好了,一切都制定。经典bfs#include #include #include using namespace std ;const int maxn = 8 + 2 ;struct Node { int r ; int c ; int step ; } node1 , node2 ;queue q ;bool visit[maxn][maxn] ;int dr[] = { -2 , -2 , -1 , -1 , 1 ,原创 2010-08-09 09:35:00 · 620 阅读 · 0 评论 -
uva 532
<br />这道题是最基本的bfs,但是在三维上玩,所以有必要说一下三维数组在计算机里的存储与我们逻辑上存储的不同。<br />在计算机里,所有的存储都不会超过一维,所谓的维,只是在你自己脑子里想象出来的(我想象过四维,但是失败了.....),它只会一行一行地帮你把数据压入栈堆,说这么抽象干嘛,举个例子吧<br />比如说,在你想象中二维数组是这么存的<br />1 2 3<br />4 5 6<br />7 8 9<br />但是它们在计算机中是这么存的: 1 2 3 4 5 6 7 8 9<br />可原创 2010-08-09 09:33:00 · 650 阅读 · 0 评论 -
uva 784(dfs)
<br />#include <iostream>#include <cstring>using namespace std ;const int maxx = 30 + 10 ;const int maxy = 80 + 10 ;struct Node { int x ; int y ; } node1 , node2 ;int r ;int bx ; int by ;char map[maxx][maxy] ;bool visit[maxx][ma原创 2010-08-08 13:31:00 · 933 阅读 · 0 评论 -
uva 784(bfs)
这个题刚开始用手动队列写的(数组版),但是运行错误不知道为什么,后来改成stl 的过了,有谁拿数组写的过了请教下我,谢谢#include #include #include using namespace std ;const int maxx = 30 + 10 ;const int maxy = 80 + 10 ;struct Node { int x ; int y ; } node1 , node2 ;queue q ;int r ;int原创 2010-08-08 13:29:00 · 491 阅读 · 0 评论 -
uva 10054
<br />还是欧拉回路,师兄帮忙,嘿嘿.........<br />#include <iostream>#include <cstring>using namespace std ;const int maxn = 50 + 10 ;int G[maxn][maxn] ;int d[maxn] ;bool visit[maxn] ;int cnt ;int node ;int bu ;void init(){ memset( G ,原创 2010-08-18 13:36:00 · 1393 阅读 · 1 评论