Language: C++

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define double long double
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;
const double EPS = 1e-9;

int m, n;
double p[17][17];
double memo[1LL << 16][17];

double rec(int mask, int id){
    if(id == n) return 1.0;
    if(mask == 0) return 0.0;
    if(memo[mask][id] > -EPS) return memo[mask][id];
    double res = 0.0;
    rep(i, 0, m){
        if(!(mask & (1LL << i))) continue;
        double tmp = 0.0, now = 1.0;
        rep(j, id, n){
            // j番目に負けた場合
            tmp += now * (1 - p[i][j]) * rec(mask - (1LL << i), j);
            now *= p[i][j];
        }
        tmp += now;#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
const int MAX_V = 10010;
const int INF = 1e9;
typedef pair<int, int> P;

struct edge{
    int u, v, d, c;
    bool operator<(const edge &e)const{
        return c < e.c;
    }
};

struct edge2{
    int to, dist, cost, id;
};

int n, m, ans;
vector<edge> es;
vector<edge2> G[MAX_V]; 
int d[MAX_V];
bool used[MAX_V];
int MINcost[MAX_V];

void dijkstra(int s){
    fill(d, d + MAX_V, INF);
    fill(MINcost, MINcost + MAX_V, INF);
    d[s] = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    q.push({0, s});
    while(!q.empty()){
        P p = q.top(); q.pop();
        int from = p.second;
        int dist = p.first;
        rep(i, 0, G[from].size()){
            edge2 e = G[from][i];
            int newDist = dist + e.dist;
            int nxt = e.to;
            if(d[nxt] > newDist){
                d[nxt] = newDist;
                MINcost[nxt] = e.cost;
                q.push({newDist, nxt});
            }else if(d[nxt] == newDist){
                MINcost[nxt] = min(MINcost[nxt], e.cost);
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        es.clear();
        es.resize(m);
        ans = 0;
        rep(i, 0, n) G[i].clear();
        rep(i, 0, m){
            cin >> es[i].u >> es[i].v >> es[i].d >> es[i].c;
            es[i].u--; es[i].v--;
            G[es[i].u].push_back({es[i].v, es[i].d, es[i].c});
            G[es[i].v].push_back({es[i].u, es[i].d, es[i].c});
        }
        sort(es.begin(), es.end());
        dijkstra(0);
        rep(i, 1, n){
            ans += MINcost[i];
        }
        cout << ans << endl;
    }
}
        res = max(res, tmp);
    }
    return memo[mask][id] = res;
}

int main(){
    cin >> m >> n;
    rep(i, 0, m) rep(j, 0, n) cin >> p[i][j];
    rep(i, 0, 1 << m) rep(k, 0, n + 1) memo[i][k] = -1.0;
    double ans = 0.0;
    ans = rec((1LL << m) - 1, 0);
    printf("%.20Lf\n", ans);
}



Compiler output:
a.cc:26:20: error: stray '#' in program
   26 |         tmp += now;#include <bits/stdc++.h>
      |                    ^
a.cc: In function 'long double rec(int, int)':
a.cc:26:21: error: 'include' was not declared in this scope
   26 |         tmp += now;#include <bits/stdc++.h>
      |                     ^~~~~~~
a.cc:26:30: error: 'bits' was not declared in this scope
   26 |         tmp += now;#include <bits/stdc++.h>
      |                              ^~~~
a.cc:26:35: error: 'stdc' was not declared in this scope; did you mean 'std'?
   26 |         tmp += now;#include <bits/stdc++.h>
      |                                   ^~~~
      |                                   std
a.cc:28:1: error: expected primary-expression before 'using'
   28 | using namespace std;
      | ^~~~~
a.cc:51:21: error: a function-definition is not allowed here before '{' token
   51 | void dijkstra(int s){
      |                     ^
a.cc:76:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   76 | int main(){
      |         ^~
a.cc:76:9: note: remove parentheses to default-initialize a variable
   76 | int main(){
      |         ^~
      |         --
a.cc:76:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:76:11: error: a function-definition is not allowed here before '{' token
   76 | int main(){
      |           ^