UVA 539 The Settlers of Catan
来源:互联网 发布:apache server 404 编辑:程序博客网 时间:2024/06/05 05:23
UVA 539 The Settlers of Catan
题目大意:第一行输入n个城市和m条路,下面m行输入m条路连接那些城市,求一条经过最多路的路径长度
解题思路:把每个点作为初始位置回溯
#include <stdio.h>#include <iostream>#include <string.h>using namespace std;int n, m;int road[30][30];int l;void dfs(int a, int b) { if(b > l) l = b; for(int i = 0; i < n; i++) { if(road[a][i]) { road[a][i]--; road[i][a]--; dfs(i, b + 1); road[a][i]++; road[i][a]++; } }}int main() { while(cin >> n >> m && n+m) { memset(road, 0, sizeof(road)); for(int i = 0; i < m; i++) { int x, y; cin >> x; cin >> y; road[x][y]++; road[y][x]++; } l = 0; for(int i = 0; i < n; i++) dfs(i, 0); cout << l << endl; } return 0;}
0 0
- UVa 539 The Settlers of Catan
- Uva 539 The Settlers of Catan
- uva 539 - The Settlers of Catan
- uva 539 - The Settlers of Catan
- uva 539 - The Settlers of Catan
- UVa 539 - The Settlers of Catan
- UVA 539 - The Settlers of Catan
- UVa 539 - The Settlers of Catan
- uva 539 The Settlers of Catan
- uva 539 - The Settlers of Catan
- UVA 539 The Settlers of Catan
- uva 539 The Settlers of Catan
- UVA 539 The Settlers of Catan
- uva 539 The Settlers of Catan
- UVa 539 - The Settlers of Catan
- uva 539 - The Settlers of Catan
- uva 539 The Settlers of Catan
- UVa 539 The Settlers of Catan
- android下面res目录
- iOS App上架流程(2016详细版)
- 浅谈堆和栈的区别
- gawk(awk)的用法案例
- “J.U.C”:ReentrantLock之一简介 (r)
- UVA 539 The Settlers of Catan
- Ext JS Theming System
- Java---代理设计模式(Proxy)
- Spring定时任务的几种实现
- VS2010+PCL1.6.0+1.7.2(Win7 64位)安装教程
- Android 修改开机动画和音乐
- bzoj4173(欧拉函数)
- 正则表达式提取html标签里的内容
- jsp数据提交至servlet中文乱码