Language: C++

include<bits/stdc++.h>
using namespace std;

struct edge{int to,cost;};
typedef pair<int,int> P;

int V;
vector<edge> g[210];
int d[210];
int inf = 1000000007;

void dijkstra(int s){
  priority_queue<P,vector<P>,greater<P>> que;
  for(int i = 0;i <= V;i++){
    d[i] = inf;
  }
  d[s] = 0;
  que.push(P(0,s));
  
  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0;i < g[v].size();i++){
      edge e = g[v][i];
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main() {
  int m,R;
  cin >> V >> m >> R;
  vector<int> r(R);
  for(int i = 0;i < R;i++){
    cin >> r.at(i);
  }
  for(int i = 0;i < m;i++){
    int a;
    edge e;
    edge f;
    cin >> a >> e.to >> e.cost;
    f.to = a;
    f.cost = e.cost;
    g[a].push_back(e);
    g[e.to].push_back(f);
  }
  int distance[210][210];
  for(int i = 0;i < R;i++){
    dijkstra(r.at(i));
    for(int j = 0;j < R;j++){
      if(i == j) continue;
      distance[r.at(i)][r.at(j)] = d[r.at(j)];
    }
  }
  
  int zyu[30][30];
  int k = 0;
  do {
    for(int i = 0;i < R;i++){
      zyu[k][i] = r.at(i);
      //cout << zyu[k][i] << " ";
    }
    //cout << k << " " << endl;
    k++;
  } while (std::next_permutation(r.begin(), r.end()));
  
  int kekka = inf;
  for(int i = 0;i < R*(R-1);i++){
    int cur = 0;
    for(int j = 0;j < R-1;j++){
      cur += distance[zyu[i][j]][zyu[i][j+1]];
    }
    kekka = min(cur,kekka);
  }
  cout << kekka << endl;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc:5:9: error: 'pair' does not name a type
    5 | typedef pair<int,int> P;
      |         ^~~~
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<edge> g[210];
      | ^~~~~~
a.cc: In function 'void dijkstra(int)':
a.cc:13:3: error: 'priority_queue' was not declared in this scope
   13 |   priority_queue<P,vector<P>,greater<P>> que;
      |   ^~~~~~~~~~~~~~
a.cc:13:18: error: 'P' was not declared in this scope
   13 |   priority_queue<P,vector<P>,greater<P>> que;
      |                  ^
a.cc:13:20: error: 'vector' was not declared in this scope
   13 |   priority_queue<P,vector<P>,greater<P>> que;
      |                    ^~~~~~
a.cc:13:29: error: expected primary-expression before ',' token
   13 |   priority_queue<P,vector<P>,greater<P>> que;
      |                             ^
a.cc:13:30: error: 'greater' was not declared in this scope
   13 |   priority_queue<P,vector<P>,greater<P>> que;
      |                              ^~~~~~~
a.cc:13:42: error: 'que' was not declared in this scope
   13 |   priority_queue<P,vector<P>,greater<P>> que;
      |                                          ^~~
a.cc:21:6: error: expected ';' before 'p'
   21 |     P p = que.top();
      |      ^~
      |      ;
a.cc:23:13: error: 'p' was not declared in this scope
   23 |     int v = p.second;
      |             ^
a.cc:25:23: error: 'g' was not declared in this scope
   25 |     for(int i = 0;i < g[v].size();i++){
      |                       ^
a.cc: In function 'int main()':
a.cc:37:3: error: 'cin' was not declared in this scope
   37 |   cin >> V >> m >> R;
      |   ^~~
a.cc:38:3: error: 'vector' was not declared in this scope
   38 |   vector<int> r(R);
      |   ^~~~~~
a.cc:38:10: error: expected primary-expression before 'int'
   38 |   vector<int> r(R);
      |          ^~~
a.cc:40:12: error: 'r' was not declared in this scope
   40 |     cin >> r.at(i);
      |            ^
a.cc:49:5: error: 'g' was not declared in this scope
   49 |     g[a].push_back(e);
      |     ^
a.cc:54:14: error: 'r' was not declared in this scope
   54 |     dijkstra(r.at(i));
      |              ^
a.cc:65:19: error: 'r' was not declared in this scope
   65 |       zyu[k][i] = r.at(i);
      |                   ^
a.cc:70:17: error: 'next_permutation' is not a member of 'std'
   70 |   } while (std::next_permutation(r.begin(), r.end()));
      |                 ^~~~~~~~~~~~~~~~
a.cc:70:34: error: 'r' was not declared in this scope
   70 |   } while (std::next_permutation(r.begin(), r.end()));
      |                                  ^
a.cc:78:13: error: 'min' was not declared in this scope; did you mean 'main'?
   78 |     kekka = min(cur,kekka);
      |             ^~~
      |             main
a.cc:80:3: error: 'cout' was not declared in this scope
   80 |   cout << kekka << endl;
      |   ^~~~
a.cc:80:20: error: 'endl' was not declared in this scope
   80 |   cout << kekka << endl;
      |                    ^~~~