输入说明:第一个输入参数为测试样例个数
第二个输入参数n为图的边数
接下来的n行输入为x,y,length,表示节点x到节点y的距离length
#include <string.h>
#include <iostream>
#include <memory.h>
#include <string>
#include <vector>
using namespace std;
bool visited[101];
int min_length = 1000000;
int start;
int enddes;
struct Node
{
int child;
int des;
Node(int a,int b)
{
this -> child = a;
this -> des = b;
}
Node(){}
};
vector<Node> data[101];
void dfs(int node,int length)
{
visited[node] = true;
if(node == enddes - 1)
{
if(length < min_length)
min_length = length;
return;
}
for(int i = 0;i < data[node].size();i++)
{
if(!visited[data[node][i].child])
{
visited[data[node][i].child] = true;
length += data[node][i].des;