Language: C++

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>
??
using namespace std;
??
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
??
//container util
//------------------------------------------
#define ALL(a)?? (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
??
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)?? FOR(i,0,n)
??
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI?? = acos(-1.0);
const LL INF = 1e14;
??
LL dist_L[201][201];
LL dist_S[201][201];
LL dp[1001][201];
int main(){
????cin.tie(0);
????ios_base::sync_with_stdio(false);
??
????int N, M, R;
????while(cin >> N >> M, N){
????????fill((LL*)dist_L, (LL*)dist_L+201*201, INF);
????????fill((LL*)dist_S, (LL*)dist_S+201*201, INF);
??
????????REP(i,N) dist_L[i][i] = dist_S[i][i] = 0;
????????REP(i,M){
????????????LL x, y, t; char c;
????????????cin >> x >> y >> t >> c;
????????????--x, --y;
????????????if(c == 'L')
????????????????dist_L[x][y] = dist_L[y][x] = min(dist_L[x][y], t);
????????????else
????????????????dist_S[x][y] = dist_S[y][x] = min(dist_S[x][y], t);
????????}
??????????
????????REP(k,N) REP(i,N) REP(j,N){
????????????dist_L[i][j] = dist_L[j][i] = min(dist_L[i][j], dist_L[i][k]+dist_L[k][j]);
????????????dist_S[i][j] = dist_S[j][i] = min(dist_S[i][j], dist_S[i][k]+dist_S[k][j]);
????????}
??
????????cin >> R;
????????VI RS(R);
????????REP(i,R){
????????????cin >> RS[i];
????????????--RS[i];
????????}
??
????????// dp[i][j] :<=> i????????????§??¨????????????????£??????????????????j??????¨???????????°??????????
????????fill((LL*)dp, (LL*)dp+1001*201, INF);
????????dp[0][RS[0]] = 0;
????????REP(i,R-1){
????????????REP(u,N){
????????????????REP(v,N){
????????????????????dp[i+1][v] = min(dp[i+1][v],
??????????????????????????????????????????????????????// Rs[i] -> u?????????§???u -> v?????????§???v->RS[i+1]?????????§??§????
??????????????????????????????????????????????????????dp[i][u]+dist_L[RS[i]][u] + dist_S[u][v]+dist_L[v][RS[i+1]]
??????????????????????????????????????????????????????);
????????????????}
????????????????//?????????
????????????????dp[i+1][u] = min(dp[i+1][u], dp[i][u]+dist_L[RS[i]][RS[i+1]]);
????????????}
????????}
??
????????LL ans = INF;
????????REP(u,N) ans = min(ans, dp[R-1][u]);
????????cout << ans << endl;
????}?? 
??????
????return 0;
}

Compiler output:
a.cc:75:11: warning: trigraph ??- ignored, use -trigraphs to enable [-Wtrigraphs]
   75 | ????????????--x, --y;
a.cc:91:11: warning: trigraph ??- ignored, use -trigraphs to enable [-Wtrigraphs]
   91 | ????????????--RS[i];
a.cc:94:7: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   94 | ????????// dp[i][j] :<=> i????????????§??¨????????????????£??????????????????j??????¨???????????°??????????
a.cc:101:53: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
  101 | ??????????????????????????????????????????????????????// Rs[i] -> u?????????§???u -> v?????????§???v->RS[i+1]?????????§??§????
a.cc:103:53: warning: trigraph ??) ignored, use -trigraphs to enable [-Wtrigraphs]
  103 | ??????????????????????????????????????????????????????);
a.cc:105:15: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
  105 | ????????????????//?????????
a.cc:26:1: error: expected unqualified-id before '?' token
   26 | ??
      | ^
a.cc:28:1: error: expected unqualified-id before '?' token
   28 | ??
      | ^
a.cc:32:9: error: 'vector' does not name a type
   32 | typedef vector<VI> VVI;
      |         ^~~~~~
a.cc:33:9: error: 'vector' does not name a type
   33 | typedef vector<string> VS;
      |         ^~~~~~
a.cc:34:9: error: 'pair' does not name a type
   34 | typedef pair<int, int> PII;
      |         ^~~~
a.cc:36:1: error: expected unqualified-id before '?' token
   36 | ??
      | ^
a.cc:56:16: error: expected initializer before '?' token
   56 | const double PI?? = acos(-1.0);
      |                ^
a.cc:58:1: error: expected unqualified-id before '?' token
   58 | ??
      | ^
a.cc: In function 'int main()':
a.cc:63:1: error: expected primary-expression before '?' token
   63 | ????cin.tie(0);
      | ^
a.cc:63:2: error: expected primary-expression before '?' token
   63 | ????cin.tie(0);
      |  ^
a.cc:63:3: error: expected primary-expression before '?' token
   63 | ????cin.tie(0);
      |   ^
a.cc:63:4: error: expected primary-expression before '?' token
   63 | ????cin.tie(0);
      |    ^
a.cc:63:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   63 | ????cin.tie(0);
      |     ^~~
      |     std::cin
In file included from a.cc:15:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:63:15: error: expected ':' before ';' token
   63 | ????cin.tie(0);
      |               ^
      |               :
a.cc:63:15: error: expected primary-expression before ';' token
a.cc:63:15: error: expected ':' before ';' token
   63 | ????cin.tie(0);
      |               ^
      |               :
a.cc:63:15: error: expected primary-expression before ';' token
a.cc:63:15: error: expected ':' before ';' token
   63 | ????cin.tie(0);
      |               ^
      |               :
a.cc:63:15: error: expected primary-expression before ';' token
a.cc:63:15: error: expected ':' before ';' token
   63 | ????cin.tie(0);
      |               ^
      |               :
a.cc:63:15: error: expected primary-expression before ';' token
a.cc:64:1: error: expected primary-expression before '?' token
   64 | ????ios_base::sync_with_stdio(false);
      | ^
a.cc:64:2: error: expected primary-expression before '?' token
   64 | ????ios_base::sync_with_stdio(false);
      |  ^
a.cc:64:3: error: expected primary-expression before '?' token
   64 | ????ios_base::sync_with_stdio(false);
      |   ^
a.cc:64:4: error: expected primary-expression before '?' token
   64 | ????ios_base::sync_with_stdio(false);
      |    ^
a.cc:64:5: error: 'ios_base' has not been declared
   64 | ????ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
a.cc:64:37: error: expected ':' before ';' token
   64 | ????ios_base::sync_with_stdio(false);
      |                                     ^
      |                                     :
a.cc:64:37: error: expected primary-expression before ';' token
a.cc:64:37: error: expected ':' before ';' token
   64 | ????ios_base::sync_with_stdio(false);
      |                                     ^
      |                                     :
a.cc:64:37: error: expected primary-expression before ';' token
a.cc:64:37: error: expected ':' before ';' token
   64 | ????ios_base::sync_with_stdio(false);
      |                                     ^
      |                                     :
a.cc:64:37: error: expected primary-expression before ';' token
a.cc:64:37: error: expected ':' before ';' token
   64 | ????ios_base::sync_with_stdio(false);
      |                                     ^
      |                                     :
a.cc:64:37: error: expected primary-expression before ';' token
a.cc:65:1: error: expected primary-expression before '?' token
   65 | ??
      | ^
a.cc:65:2: error: expected primary-expression before '?' token
   65 | ??
      |  ^
a.cc:66:1: error: expected primary-expression before '?' token
   66 | ????int N, M, R;
      | ^
a.cc:66:2: error: expected primary-expression before '?' token
   66 | ????int N, M, R;
      |  ^
a.cc:66:3: error: expected primary-expression before '?' token
   66 | ????int N, M, R;
      |   ^
a.cc:66:4: error: expected primary-expression before '?' token
   66 | ????int N, M, R;
      |    ^
a.cc:66:5: error: expected primary-expression before 'int'
   66 | ????int N, M, R;
      |     ^~~
a.cc:66:5: error: expected ':' before 'int'
   66 | ????int N, M, R;
      |     ^~~
      |     :
a.cc:66:5: error: expected primary-expression before 'int'
   66 | ????int N, M, R;
      |     ^~~
a.cc:66:5: error: expected ':' before 'int'
   66 | ????int N, M, R;
      |     ^~~
      |     :
a.cc:66:5: error: expected primary-expression before 'int'
   66 | ????int N, M, R;
      |     ^~~
a.cc:66:5: error: expected ':' before 'int'
   66 | ????int N, M, R;
      |     ^~~
      |     :
a.cc:66:5: error: expected primary-expression before 'int'
   66 | ????int N, M, R;
      |     ^~~
a.cc:66:5: error: expected ':' before 'int'
   66 | ????int N, M, R;
      |     ^~~
      |     :
a.cc:66:5: error: expected primary-expression before 'int'
   66 | ????int N, M, R;
      |     ^~~
a.cc:66:5: error: expected ':' before 'int'
   66 | ????int N, M, R;
      |     ^~~
      |     :
a.cc:66:5: error: expected primary-expression before 'int'
   66 | ????int N, M, R;
      |     ^~~
a.cc:66:5: error: expected ':' before 'int'
   66 | ????int N, M, R;
      |     ^~~
      |     :
a.cc:66:5: error: expected primary-expression before 'int'
   66 | ????int N, M, R;
      |     ^~~
a.cc:67:1: error: expected primary-expression before '?' token
   67 | ????while(cin >> N >> M, N){
      | ^
a.cc:67:2: error: expected primary-expression before '?' token
   67 | ????while(cin >> N >> M, N){
      |  ^
a.cc:67:3: error: expected primary-expression before '?' token
   67 | ????while(cin >> N >> M, N){
      |   ^
a.cc:67:4: error: expected primary-expression before '?' token
   67 | ????while(cin >> N >> M, N){
      |    ^
a.cc:67:5: error: expected primary-expression before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
a.cc:67:5: error: expected ':' before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
      |     :
a.cc:67:5: error: expected primary-expression before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
a.cc:67:5: error: expected ':' before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
      |     :
a.cc:67:5: error: expected primary-expression before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
a.cc:67:5: error: expected ':' before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
      |     :
a.cc:67:5: error: expected primary-expression before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
a.cc:67:5: error: expected ':' before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
      |     :
a.cc:67:5: error: expected primary-expression before 'while'
   67 | ????while(cin >> N >> M, N){
      |     ^~~~~
a.cc:113:6: error: expected primary-expression before '?' token
  113 | ????}??
      |      ^
a.cc:113:7: error: expected primary-expression before '?' token
  113 | ????}??
      |       ^
a.cc:114:1: error: expected primary-expression before '?' token
  114 | ??????
      | ^
a.cc:114:2: error: expected primary-expression before '?' token
  114 | ??????
      |  ^
a.cc:114:3: error: expected primary-expression before '?' token
  114 | ??????
      |   ^
a.cc:114:4: error: expected primary-expression before '?' token
  114 | ??????
      |    ^
a.cc:114:5: error: expected primary-expression before '?' token
  114 | ??????
      |     ^
a.cc:114:6: error: expected primary-expression before '?' token
  114 | ??????
      |      ^
a.cc:115:1: error: expected primary-expression before '?' token
  115 | ????return 0;
      | ^
a.cc:115:2: error: expected primary-expression before '?' token
  115 | ????return 0;
      |  ^
a.cc:115:3: error: expected primary-expression before '?' token
  115 | ????return 0;
      |   ^
a.cc:115:4: error: expected primary-expression before '?' token
  115 | ????return 0;
      |    ^
a.cc:115:5: error: expected primary-expression before 'return'
  115 | ????return 0;
      |     ^~~~~~
a.cc:115:5: error: expected ':' before 'return'
  115 | ????return 0;
      |     ^~~~~~
      |     :
a.cc:115:5: error: expected primary-expression before 'return'
  115 | ????return 0;
      |     ^~~~~~
a.cc:115:5: error: expected ':' before 'return'
  115 | ????return 0;
      |     ^~~~~~
      |     :
a.cc:115:5: error: expected primary-expression before 'return'
  115 | ????return 0;
      |     ^~~~~~
a.cc:115:5: error: expected ':' before 'return'
  115 | ????return 0;
      |     ^~~~~~
      |     :
a.cc:115:5: error: expected primary-expression before 'return'
  115 | ????return 0;
      |     ^~~~~~
a.cc:115:5: error: expected ':' before 'return'
  115 | ????return 0;
      |     ^~~~~~
      |     :
a.cc:115:5: error: expected primary-expression before 'return'
  115 | ????return 0;
      |     ^~~~~~
a.cc:115:5: error: expected ':' before 'return'
  115 |