图
冰阔落
Stay hungry, Stay foolish, Stop when you are perfect.
展开
-
UVA 10004 - Bicoloring
#include #include int edge[205][205], vis[205], flag, n; bool dfs(int cur, int color) { for (int i = 0; i < n; i++) if (edge[cur][i] && vis[i] == vis[cur]) flag = 0; for (int i = 0; i < n原创 2014-08-17 14:19:31 · 1636 阅读 · 0 评论 -
UVA 10054 - The Necklace
#include #include int node[55], edge[55][55] = {0}; int find_father(int x) { return x != node[x] ? node[x] = find_father(node[x]) : x; } int dfs(int cur) { for (int i = 0; i < 51; i++) if (ed原创 2014-08-18 14:45:40 · 1655 阅读 · 0 评论 -
UVA 10129 - Play on Words
#include #include int node[26]; int find_father(int x) { return x != node[x] ? node[x] = find_father(node[x]) : x; } int main() { int t; scanf("%d", &t); while (t--) { int outdegree[26] =原创 2014-08-17 20:11:34 · 1574 阅读 · 0 评论 -
UVA 10596 - Morning Walk
#include int node[201], degree[201]; int find(int x) { if (x != node[x]) //假如此结点连接了其他结点, 就寻找它所连接的结点是否又连接了其他结点 return node[x] = find(node[x]); //此联通路上面的所有结点都指向同一个端点 return x; } int原创 2014-08-12 14:21:11 · 1506 阅读 · 0 评论 -
UVA 532 - Dungeon Master
#include #include using namespace std; int level, row, column; int dir[6][3] = {{1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}}; char dungeon[35][35][35]; struct Node { int x;原创 2014-08-10 20:20:05 · 1479 阅读 · 0 评论 -
UVA 439 - Knight Moves
#include int x, y, max, dir[8][2] = {{2, 1}, {2, -1}, {-2, -1}, {-2, 1}, {-1, -2}, {-1, 2}, {1, -2}, {1, 2}}; void explore(int a, int b, int step) { if (a 7 || b 7 || step >= max) //如果越界则说明原创 2014-08-10 09:34:42 · 1588 阅读 · 0 评论 -
UVA 784 Maze Exploration
#include char data[35][85]; int row, column, dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; void explor(int x, int y) { if (data[x][y] == '#' || data[x][y] == 'X' || x < 0 || x == row || y < 0 ||原创 2014-08-08 14:49:31 · 1631 阅读 · 0 评论 -
UVA 657 The die is cast
#include char data[55][55]; int row, column, count = 0, dir[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; bool find_dot(int x, int y) { if (data[x][y] != 'X' || x < 0 || x == row || y < 0 || y == col原创 2014-08-08 14:08:12 · 1510 阅读 · 0 评论 -
UVA 572 Oil Deposits
#include char data[150][150]; int row, column; bool find(int x, int y) { if (data[x][y] == '*' || x < 0 || x == row || y < 0 || y == column) //遇到边界、已来过、非油田就结束 return false; data[x][y] = '*'; //原创 2014-08-07 21:25:13 · 1529 阅读 · 0 评论 -
UVA 705 Slash Maze
#include #include char data[80][80], maze[240][240]; int row, column, flag, step, dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; bool find_cycle(int x, int y) { if (x < 0 || x == 3 * row || y < 0原创 2014-08-08 20:04:40 · 1594 阅读 · 0 评论 -
UVA 10305 - Ordering Tasks
#include int main() { int n, m; while (scanf("%d%d", &n, &m), n) { int edge[105][105] = {0}, indegree[105] = {0}; for (int i = 0; i < m; i++) { int a, b; scanf("%d%d", &a, &b); edge[a原创 2014-08-18 18:17:41 · 1622 阅读 · 0 评论