Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <iterator>
#include <bitset>
#include <random>
#include <assert.h>
#include <unordered_map>
#include <array>
#include <ctime>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define MP make_pair
#define umap unordered_map

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> P;
typedef unsigned int uint;

const int N = 55;

int d[N][N];
vector<P> G[N];
int ball[N];
int bpos[N];

struct state{
	int pos, visit, total;
	//int dist;
	bool operator < (const state &r) const{
		//return total+dist > r.total+r.dist;
		return total > r.total;
	}
};

int main(){
	ios::sync_with_stdio(false);

	int n, m, l, k;
	while (cin >> n >> m >> l >> k, n | m | l | k){
		rep(i, N) rep(j, N) d[i][j] = 1 << 29;
		rep(i, N) G[i].clear();
		MEMSET(ball, 0);
		MEMSET(bpos, 0);
		rep(i, m){
			int u, v, c;
			cin >> u >> v >> c;
			--u, --v;
			d[u][v] = d[v][u] = c;
			G[u].push_back(MP(v, c));
			G[v].push_back(MP(u, c));
		}
		int s, g;
		cin >> s >> g;
		--s, --g;
		rep(i, l){
			int b;
			cin >> b;
			ball[--b] = 1 << i;
			bpos[i] = b;
		}
		rep(i, n) rep(j, n) rep(k, n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

		priority_queue<state> q;
		q.push({s, 0, 0, 0});

		auto get_dist = [l, g](state &s){
			int res = d[s.pos][g];
			rep(i, l) if (~s.visit&(1 << i)) res += d[s.pos][bpos[i]];
			return res;
		};


		int cnt = 0, ans = -1;
		if (d[s][g] >= 1 << 29) goto fail;
		while (!q.empty()) {
			auto s = q.top();
			q.pop();

			s.visit |= ball[s.pos];

			if (s.pos == g && s.visit + 1 == (1 << l)){
				//cout << s.total << endl;
				if (++cnt == k){
					ans = s.total;
					break;
				}
			}

			for (auto e : G[s.pos]){
				state nxt = s;
				nxt.pos = e.first;
				nxt.total += e.second;
				//nxt.dist = get_dist(nxt);
				q.push(nxt);
			}
		}

	fail:;
		if(ans >= 0) cout << ans << endl;
		else cout << "NA" << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:92:23: error: no matching function for call to 'std::priority_queue<state>::push(<brace-enclosed initializer list>)'
   92 |                 q.push({s, 0, 0, 0});
      |                 ~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:10:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = state; _Sequence = std::vector<state, std::allocator<state> >; _Compare = std::less<state>; value_type = state]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<state>::value_type&' {aka 'const state&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = state; _Sequence = std::vector<state, std::allocator<state> >; _Compare = std::less<state>; value_type = state]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<state>::value_type&&' {aka 'state&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~