ACM: uva 1424 - Salesmen
来源:互联网 发布:网络延迟多少ms算正常 编辑:程序博客网 时间:2024/06/06 02:58
Salesmen
Traveling salesmen of
For example on the following graph representing theworking area of a salesman,
a reported working path [1 2 2 6 5 5 5 7 4] is acorrect path. But a reported working path [1 2 2 7 5 5 5 7 4] isnot a correct path since there is no edge in the graph betweenvertices 2 a 7. If we assume that the salesman reports his locationevery time when he has to report his location (but possiblyincorrectly), thenthe
The length of a working path is the number ofvertices in the path. We definethe
Given a graph representing the working area of asalesman and a working path (possible not a correctpath),
Input
The program is to read the input from standardinput. The input consistsof
Output
Your program is to write to standard output. Printone line for each test case. The line should contain the minimumdistance of the input path to a correct path of the samelength.
SampleInput
2
7 9
1 2
2 3
2 4
2 6
3 4
4 5
5 6
7 4
7 5
9 1 2 2 7 5 5 5 7 4
7 9
1 2
2 3
2 4
2 6
3 4
4 5
5 6
7 4
7 5
9 1 2 2 6 5 5 5 7 4
SampleOutput
1
0
题意: 有出n个节点的无向图, 并且给出一段序列, 现在要求你修改最少的次数, 使得序列的任意相邻的两个
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 205
const int INF = (1<<29);
int n, m;
int g[MAX][MAX];
int num, a[MAX];
int dp[MAX][MAX];
inline int min(int a, int b)
{
}
int main()
{
//
}
- ACM: uva 1424 - Salesmen
- ACM: uva 1335 - Beijing Guards
- ACM: uva 10391 - Compound Words
- ACM: uva 10534 - Wavio Sequence
- ACM: uva 11538 - Chess Queen
- ACM: uva 1073 - Glenbow Museum
- ACM: 数学题 uva 11300
- ACM: uva 11584 -
- ACM: uva 11464
- ACM: uva 3902
- ACM: uva 10382
- ACM: uva 11134
- ACM: uva 11174 - Stand in a Line
- ACM: uva 1276 - Network
- ACM: uva 1450 - Airport
- ACM: uva 1467 - Installations
- ACM: uva 10125 - Sumsets
- ACM: uva 1451 - Average
- ACM: poj 2786 -&n…
- jquery 1.6 后 checkbox 使用attr("checked"),undefined.
- ACM: poj 3972 -&n…
- ACM: uva 1468 - Restaurant
- ACM: uva 11584 -
- ACM: uva 1424 - Salesmen
- ACM: uva 10534 - Wavio Sequence
- ACM: uva 11538 - Chess Queen
- ACM: uva 11401 - Triangle Counti…
- ACM: uva 11375 - Matches
- ACM: uva 11174 - Stand in a Line
- ACM: uva 1362 -&n…
- ACM: uva 11361 -&…
- ACM: uva 1073 - Glenbow Museum