Language: C++

#include <bits/stdc++.h>
using namespace std;
long long mapp[230*230][230*230];
int vis[230*220];
int num[220];
struct node
{
    int a,b,c;
}arr[220*220];
int pre[220*220];
long long sum;
bool cmp(node aa,node bb)
{
    if(aa.c==bb.c) return aa.a<bb.a;
    if(aa.a==bb.a) return aa.b<bb.b;
}

int main()
{
    int n,m,r;
    while(~scanf("%d%d%d",&n,&m,&r))
    {
        int a,b,c;
        for(int i=0;i<r;i++)
        {
            scanf("%d",&num[i]);
        }
        for(int i=1;i<230;i++)
        {
            for(int j=1;j<230;j++)
            {
                if(i==j) mapp[i][j]=0;
                else mapp[i][j]=10000000;
            }
        }
        for(int i=0;i<m;i++)
        {
            scanf("%d%d%d",&a,&b,&c);
            arr[i].a=a;
            arr[i].b=b;
            arr[i].c=c;
            if(mapp[a][b]==0 || c<mapp[a][b])
            {
                mapp[a][b]=c;
                mapp[b][a]=c;
            }
        }
        sort(arr,arr+n,cmp);
        sum=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                for(int k=1;k<=n;k++)
                {
                    if(i!=j&& j!=k)
                    {
                        if(mapp[i][j]>mapp[i][k]+mapp[k][j])
                        {
                            mapp[i][j]=mapp[i][k]+mapp[k][j];
                        }
                    }
                }
            }
        }
        int minn=19000000;
        int ans1;
        for(int i=0;i<r;i++)
        {
            vis[num[i]]=1;
            for(int j=i+1;j<r;j++)
            {
                if(!vis[num[j]])
                {
                    if(mapp[num[i]][num[j]]<minn)
                    {
                        minn=mapp[num[i]][num[j]];
                        ans1=num[j];
                    }
                }
            }
            vis[ans1]=1;
            sum+=mapp[num[i]][ans1];
        }
        cout<<sum<<endl;
    }
}


Compiler output:
a.cc: In function 'bool cmp(node, node)':
a.cc:16:1: warning: control reaches end of non-void function [-Wreturn-type]
   16 | }
      | ^
/tmp/ccBRqtqs.o: in function `main':
a.cc:(.text+0x78): relocation truncated to fit: R_X86_64_PC32 against symbol `num' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x17f): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x1a2): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x1c5): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x2b1): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x2c5): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x2d4): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x467): relocation truncated to fit: R_X86_64_PC32 against symbol `num' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x47b): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x4a4): relocation truncated to fit: R_X86_64_PC32 against symbol `num' defined in .bss section in /tmp/ccBRqtqs.o
a.cc:(.text+0x4b8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status