#include #include using namespace std; using namespace atcoder; typedef long long ll; typedef long double ld; #define sz(c) ((ll)(c).size()) #define ALL(x) x.begin(),x.end() #define LB(A,x) (ll)(lower_bound(ALL(A),x)-A.begin()) #define UB(A,x) (ll)(upper_bound(ALL(A),x)-A.begin()) #define BS(A,x) binary_search(ALL(A),x) #define rep(i,a,b) for(int i=a;ibool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } using vi = vector; using vvi = vector; using li =vector; using lli=vector
  • ; const long long mod=998244353; int main(){ ll n,m,k;cin>>n>>m>>k; vi A(n); lli T(n,li(n)); rep(i,0,k){ int a;cin>>a;a--;A[a]++; } rep(i,0,n)rep(j,0,n)cin>>T[i][j]; ll ans=1e18; if(m==1){cout<<0;return 0;} rep(i,0,n){ lli dp((1LL<>p)%2==1)cnt++; //現在地 rep(p,0,n){ if((j>>p)%2==0)continue; //向かう頂点 rep(q,0,n){ //すでに行ったことがある if((j>>q)%2==1){ if(cnt>=m&&A[q]==1)ans=min(ans,dp[j][p]+T[p][q]); } else { if(cnt+1>=m&&A[q]==1)ans=min(ans,dp[j][q]+T[p][q]); dp[j+(1LL<