Language: C++

#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

typedef pair<double,pair<int,int> > type;

void solve(int n,int m,int p,int a,int b){
  a--;b--;
  vector<int> t(m);
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  
  int dist[30][30];
  for(int i=0;i<30;i++){
    for(int j=0;j<30;j++)dist[i][j]=-1;
  }
  
  vector<int> x(p),y(p),z(p);
  for(int i=0;i<p;i++){
    cin>>x[i]>>y[i]>>z[i];
    x[i]--;y[i]--;
    dist[x[i]][y[i]]=dist[y[i]][x[i]]=z[i];
  }
  
  double dp[30][1<<8];
  for(int i=0;i<30;i++){
    for(int j=0;j<(1<<8);j++)dp[i][j]=1e12;
  }
  dp[a][0]=0;
  
  // first -> コスト | second.first -> 現在地 second.second -> bit mask
  priority_queue<type,vector<type>,greater<type> > que;
  que.push(mp(0,mp(a,0)));
  while(que.size()){
    type top=que.top();que.pop();
    double cost=top.first;
    int now=top.second.first,now_mask=top.second.second;
    if(cost>dp[now][now_mask])continue;
    for(int i=0;i<m;i++)if(dist[now][i]!=-1){
	for(int j=0;j<n;j++){
	  int next_mask=now_mask;
	  if(next_mask & (1<<j))continue;
	  next_mask|=(1<<j);
	  double next_cost=cost+double(dist[now][i])/t[j];;
	  if(dp[i][next_mask]>next_cost){
	    dp[i][next_mask]=next_cost;
	    que.push(mp(next_cost,mp(i,next_mask)));
	  }
	}
      }
  }
  double ans=1e12;
  for(int i=0;i<(1<<8);i++){
    ans=min(ans,dp[b][i]);
  }
  if(ans==1e12)cout<<"Impossible"<<endl;
  else cout<<ans<<endl;
}

int main(){
  int n,m,p,a,b;
  while(cin>>n>>m>>p>>a>>b){
    if(!(n|m|p|a|b))break;
    solve(n,m,p,a,b);
  }
  return 0;
}



Compiler output:
a.cc:11:9: error: 'vector' does not name a type
   11 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:12:9: error: 'vector' does not name a type
   12 | typedef vector<long long>vll;
      |         ^~~~~~
a.cc:13:9: error: 'pair' does not name a type
   13 | typedef pair<int,int> pi;
      |         ^~~~
a.cc:22:9: error: 'pair' does not name a type
   22 | typedef pair<double,pair<int,int> > type;
      |         ^~~~
a.cc: In function 'void solve(int, int, int, int, int)':
a.cc:26:3: error: 'vector' was not declared in this scope
   26 |   vector<int> t(m);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #define rrep(i,n) for(int i=n-1;i>=0;i--)
a.cc:26:10: error: expected primary-expression before 'int'
   26 |   vector<int> t(m);
      |          ^~~
a.cc:28:5: error: 'cin' was not declared in this scope
   28 |     cin>>t[i];
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define rrep(i,n) for(int i=n-1;i>=0;i--)
a.cc:28:10: error: 't' was not declared in this scope
   28 |     cin>>t[i];
      |          ^
a.cc:36:10: error: expected primary-expression before 'int'
   36 |   vector<int> x(p),y(p),z(p);
      |          ^~~
a.cc:38:5: error: 'cin' was not declared in this scope
   38 |     cin>>x[i]>>y[i]>>z[i];
      |     ^~~
a.cc:38:5: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:38:10: error: 'x' was not declared in this scope
   38 |     cin>>x[i]>>y[i]>>z[i];
      |          ^
a.cc:38:16: error: 'y' was not declared in this scope
   38 |     cin>>x[i]>>y[i]>>z[i];
      |                ^
a.cc:38:22: error: 'z' was not declared in this scope
   38 |     cin>>x[i]>>y[i]>>z[i];
      |                      ^
a.cc:50:3: error: 'priority_queue' was not declared in this scope
   50 |   priority_queue<type,vector<type>,greater<type> > que;
      |   ^~~~~~~~~~~~~~
a.cc:1:1: note: 'std::priority_queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
  +++ |+#include <queue>
    1 | #define rrep(i,n) for(int i=n-1;i>=0;i--)
a.cc:50:18: error: 'type' was not declared in this scope; did you mean 'typeof'?
   50 |   priority_queue<type,vector<type>,greater<type> > que;
      |                  ^~~~
      |                  typeof
a.cc:50:35: error: expected primary-expression before ',' token
   50 |   priority_queue<type,vector<type>,greater<type> > que;
      |                                   ^
a.cc:50:36: error: 'greater' was not declared in this scope
   50 |   priority_queue<type,vector<type>,greater<type> > que;
      |                                    ^~~~~~~
a.cc:50:50: error: expected primary-expression before '>' token
   50 |   priority_queue<type,vector<type>,greater<type> > que;
      |                                                  ^
a.cc:50:52: error: 'que' was not declared in this scope
   50 |   priority_queue<type,vector<type>,greater<type> > que;
      |                                                    ^~~
a.cc:5:12: error: 'make_pair' was not declared in this scope
    5 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:51:17: note: in expansion of macro 'mp'
   51 |   que.push(mp(0,mp(a,0)));
      |                 ^~
a.cc:1:1: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | #define rrep(i,n) for(int i=n-1;i>=0;i--)
a.cc:5:12: error: 'make_pair' was not declared in this scope
    5 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:51:12: note: in expansion of macro 'mp'
   51 |   que.push(mp(0,mp(a,0)));
      |            ^~
a.cc:5:12: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
    5 | #define mp make_pair
      |            ^~~~~~~~~
a.cc:51:12: note: in expansion of macro 'mp'
   51 |   que.push(mp(0,mp(a,0)));
      |            ^~
a.cc:53:9: error: expected ';' before 'top'
   53 |     type top=que.top();que.pop();
      |         ^~~~
      |         ;
a.cc:54:17: error: 'top' was not declared in this scope
   54 |     double cost=top.first;
      |                 ^~~
a.cc:56:21: error: 'now_mask' was not declared in this scope
   56 |     if(cost>dp[now][now_mask])continue;
      |                     ^~~~~~~~
a.cc:59:25: error: 'now_mask' was not declared in this scope; did you mean 'next_mask'?
   59 |           int next_mask=now_mask;
      |                         ^~~~~~~~
      |                         next_mask
a.cc:62:54: error: 't' was not declared in this scope
   62 |           double next_cost=cost+double(dist[now][i])/t[j];;
      |                                                      ^
a.cc:72:9: error: 'min' was not declared in this scope
   72 |     ans=min(ans,dp[b][i]);
      |         ^~~
a.cc:74:16: error: 'cout' was not declared in this scope
   74 |   if(ans==1e12)cout<<"Impossible"<<endl;
      |                ^~~~
a.cc:74:16: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:74:36: error: 'endl' was not declared in this scope
   74 |   if(ans==1e12)cout<<"Impossible"<<endl;
      |                                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define rrep(i,n) for(int i=n-1;i>=0;i--)
a.cc:75:8: error: 'cout' was not declared in this scope
   75 |   else cout<<ans<<endl;
      |        ^~~~
a.cc:75:8: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:75:19: error: 'endl' was not declared in this scope
   75 |   else cout<<ans<<endl;
      |                   ^~~~
a.cc:75:19: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc: In function 'int main()':
a.cc:80:9: error: 'cin' was not declared in this scope
   80 |   while(cin>>n>>m>>p>>a>>b){
      |         ^~~
a.cc:80:9: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'