#include<iostream>
#include<vector>
using namespace std;
void main()
{
    vector<int>T;
    vector<int>L;
    int Min(int x,int y);
    int i,j,k,m,n,p1,p2,a[8][8],min=0,t;
    cout<<"请输入你的连通图a[8][8]:"<<endl;
    for(i=1;i<8;i++)
        for(j=1;j<8;j++)
            cin>>m;
        cout<<"请输入所要寻找的两个点:"<<endl;
        cin>>p1>>p2;
        cout<<"请输入所有顶点集合:"<<endl;
        for(i=1;i<8;i++)
        {
            cin>>m;
            T.push_back(m);
        }
        cout<<"请输入所有顶点初始距离:"<<endl;
        for(j=1;j<8;j++)
        {
            cin>>n;
            L.push_back(n);
        }
        for(i=0;i<T.size();i++)
        {
            t=0;
                if(a[p1][T[i]]!=100)
                {
                    t++;
                    L[i]=Min(L[i],min+a[p1][T[i]]);
                }
                if(t==0)
                    break;
            min=L[0];
            for(k=0;k<L.size();k++)
            {
                if(L[k]<min)
                    min=L[k];
            }
            T.erase(&k);
            p1=k;
        }
        cout<<"最短距离:"<<L[p1]<<endl;
}
int Min(int x,int y)
{
    return (x<y)?x:y;
}