2012年11月16日

UVA 784 - Maze Exploration

摘要: 水题,了解了dfs后,这样的题就水的很了。代码如下:#include #include #include using namespace std; char ch[50][100]; void dfs(int i, int j) { if(ch[i][j] == '#'||ch[i][j]=='X')return; ch[i][j] = '#'; dfs(i-1, j-1);dfs(i-1, j);dfs(i-1, j+1); dfs(i, j-1); dfs(i, j+1); dfs(i+1, j-1);dfs(i+1,... 阅读全文
posted @ 2012-11-16 21:01 Primo... 阅读(129) 评论(0) 推荐(0)

UVA657 - The die is cast

摘要: 这个水题还是让我WA了好几遍,原因是没读清题意。思路很简单,就是DFS两遍就行了代码如下:#include #include using namespace std; char ch[55][55]; int count, pot[7];//用pot[1],pot[2……]分别储存点数为1,2……出现的次数;然后就很容易的由小到大的输出了; bool vis[55][55],visx[55][55]; void input(int w, int h) { for(int i = 1; i >w>>h&&w&&h) { cin.ignore(); 阅读全文
posted @ 2012-11-16 20:01 Primo... 阅读(133) 评论(0) 推荐(0)