Language: C++

#include <cstdio>
#include <algorithm>

constexpr int INF = 1000000000;
constexpr int MAX_V = 15;

int V, E;
int memo[1 << MAX_V][MAX_V] = {-1}, dis[MAX_V][MAX_V] = {-1};

int tsp(int s = 1, int v = 0);

int main(){
    scanf("%d%d", &V, &E);
    for(int i = 0; i < 1 << V; ++i){
        for(int j = 0; j < V; ++j){
            memo[i][j] = -1;
        }
    }
    for(int i = 0; i < V; ++i){
        for(int j = 0; j < V; ++j){
            dis[i][j] = INF;
        }
    }
    for(int i = 0; i < E; ++i){
        int s, t, d;
        scanf("%d%d%d", &s, &t, &d);
        dis[s][t] = d;
    }
    int tmp = tsp();
    if(tmp >= INF){
        puts("-1");
    }
    else{
        printf("%d\n", tmp);
    }
    return 0;
}

int tsp(int s, int v){
    if(memo[s][v] != -1){
        return memo[s][v];
    }
    if(s == ((1 << V) - 1)){
        return dis[v][0];
    }
    
    int res = INF;
    for(int i = 0; i < V; ++i){
        if(s & 1 << i){
            continue;
        }
        res = std::min(res, tsp(s | (1 << i), i) + dis[v][i]);
    }

    return memo[s][v] = res;
}
#include <cstdio>
#include <algorithm>

constexpr int INF = 1000000000;
constexpr int MAX_V = 15;

int V, E;
int memo[1 << MAX_V][MAX_V] = {-1}, dis[MAX_V][MAX_V] = {-1};

int tsp(int s = 1, int v = 0);

int main(){
    scanf("%d%d", &V, &E);
    for(int i = 0; i < 1 << V; ++i){
        for(int j = 0; j < V; ++j){
            memo[i][j] = -1;
        }
    }
    for(int i = 0; i < V; ++i){
        for(int j = 0; j < V; ++j){
            dis[i][j] = INF;
        }
    }
    for(int i = 0; i < E; ++i){
        int s, t, d;
        scanf("%d%d%d", &s, &t, &d);
        dis[s][t] = d;
    }
    int tmp = tsp();
    if(tmp >= INF){
        puts("-1");
    }
    else{
        printf("%d\n", tmp);
    }
    return 0;
}

int tsp(int s, int v){
    if(memo[s][v] != -1){
        return memo[s][v];
    }
    if(s == ((1 << V) - 1)){
        return dis[v][0];
    }
    
    int res = INF;
    for(int i = 0; i < V; ++i){
        if(s & 1 << i){
            continue;
        }
        res = std::min(res, tsp(s | (1 << i), i) + dis[v][i]);
    }

    return memo[s][v] = res;
}

Compiler output:
a.cc:60:15: error: redefinition of 'constexpr const int INF'
   60 | constexpr int INF = 1000000000;
      |               ^~~
a.cc:4:15: note: 'constexpr const int INF' previously defined here
    4 | constexpr int INF = 1000000000;
      |               ^~~
a.cc:61:15: error: redefinition of 'constexpr const int MAX_V'
   61 | constexpr int MAX_V = 15;
      |               ^~~~~
a.cc:5:15: note: 'constexpr const int MAX_V' previously defined here
    5 | constexpr int MAX_V = 15;
      |               ^~~~~
a.cc:63:5: error: redefinition of 'int V'
   63 | int V, E;
      |     ^
a.cc:7:5: note: 'int V' previously declared here
    7 | int V, E;
      |     ^
a.cc:63:8: error: redefinition of 'int E'
   63 | int V, E;
      |        ^
a.cc:7:8: note: 'int E' previously declared here
    7 | int V, E;
      |        ^
a.cc:64:5: error: redefinition of 'int memo [32768][15]'
   64 | int memo[1 << MAX_V][MAX_V] = {-1}, dis[MAX_V][MAX_V] = {-1};
      |     ^~~~
a.cc:8:5: note: 'int memo [32768][15]' previously defined here
    8 | int memo[1 << MAX_V][MAX_V] = {-1}, dis[MAX_V][MAX_V] = {-1};
      |     ^~~~
a.cc:64:37: error: redefinition of 'int dis [15][15]'
   64 | int memo[1 << MAX_V][MAX_V] = {-1}, dis[MAX_V][MAX_V] = {-1};
      |                                     ^~~
a.cc:8:37: note: 'int dis [15][15]' previously defined here
    8 | int memo[1 << MAX_V][MAX_V] = {-1}, dis[MAX_V][MAX_V] = {-1};
      |                                     ^~~
a.cc:66:5: error: default argument given for parameter 1 of 'int tsp(int, int)' [-fpermissive]
   66 | int tsp(int s = 1, int v = 0);
      |     ^~~
a.cc:39:5: note: previous specification in 'int tsp(int, int)' here
   39 | int tsp(int s, int v){
      |     ^~~
a.cc:66:5: error: default argument given for parameter 2 of 'int tsp(int, int)' [-fpermissive]
   66 | int tsp(int s = 1, int v = 0);
      |     ^~~
a.cc:39:5: note: previous specification in 'int tsp(int, int)' here
   39 | int tsp(int s, int v){
      |     ^~~
a.cc:68:5: error: redefinition of 'int main()'
   68 | int main(){
      |     ^~~~
a.cc:12:5: note: 'int main()' previously defined here
   12 | int main(){
      |     ^~~~
a.cc:95:5: error: redefinition of 'int tsp(int, int)'
   95 | int tsp(int s, int v){
      |     ^~~
a.cc:39:5: note: 'int tsp(int, int)' previously defined here
   39 | int tsp(int s, int v){
      |     ^~~