Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

#define INF INT_MAX>>1

using namespace std;

int main(void){
	while(1){
		int n, m, c, s, g; 
		cin >> n >> m >> c >> s >> g;
		if(!n && !m && !c && !s && !g) break;
		s--; g--;

		static int dist[100][100][20];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				for(int k=0; k<c; k++){
					if(i==j) dist[i][j][k] = 0;
					else dist[i][j][k] = INF;
				}
			}
		}
		for(int i=0; i<m; i++){
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--; c--;
			dist[x][y][c] = dist[y][x][c] = min(dist[x][y][c], d);
		}

		int p[20];//int len[20];
		for(int i=0; i<c; i++) {
			cin >> p[i];// scanf("%d",len+i);
		}
		vector< pair<int, int> > poly[20];
		for(int i=0; i<c; i++){
			poly[i].assign(p[i]+1, make_pair(0, 1));
			for(int j=0; j<p[i]-1; j++){
				int q; cin >> q;
				poly[i][j+1].first = q;
			}
			for(int j=0; j<p[i]; j++){
				int r; cin >> r;
				poly[i][j+1].second = r;
			}
			poly[i].back().first=INF;//????
		}

		for(int l=0; l<c; l++){
			//ワーシャルフロイド
			for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++){
				dist[i][j][l] = min(dist[i][j][l], dist[i][k][l]+dist[k][j][l]);
				cout << dist[i][j][l] << endl;
			}

		}

		static int cost[100][100][20];
		for(int l=0; l<c; l++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					int d = dist[i][j][l];
					if(d == INF){
						cost[i][j][l] = INF;//????
						continue;
					}
					int tmp=0;
					for(int k=0; k<poly[l].size()-1; k++){
						tmp += poly[l][k+1].second*max(min(poly[l][k+1].first, d)-poly[l][k].first, 0);
					}
					cost[i][j][l] = tmp;
					//cout << cost[i][j][l] << endl;

				}
			}
		}

		int ans[100][100];
		fill(ans[0], ans[100], INF);
		for(int i=0; i<n; i++) for(int j=0; j<n; j++) for(int k=0; k<c; k++) {
			ans[i][j] = min(ans[i][j], cost[i][j][k]);
		}
		for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++) ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j]);

		if(ans[s][g] != INF) cout << ans[s][g] << endl;
		else cout << -1 << endl;
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:13: error: 'INT_MAX' was not declared in this scope
    5 | #define INF INT_MAX>>1
      |             ^~~~~~~
a.cc:21:62: note: in expansion of macro 'INF'
   21 |                                         else dist[i][j][k] = INF;
      |                                                              ^~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 | 
a.cc:5:13: error: 'INT_MAX' was not declared in this scope
    5 | #define INF INT_MAX>>1
      |             ^~~~~~~
a.cc:47:46: note: in expansion of macro 'INF'
   47 |                         poly[i].back().first=INF;//????
      |                                              ^~~
a.cc:5:13: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #define INF INT_MAX>>1
      |             ^~~~~~~
a.cc:47:46: note: in expansion of macro 'INF'
   47 |                         poly[i].back().first=INF;//????
      |                                              ^~~
a.cc:5:13: error: 'INT_MAX' was not declared in this scope
    5 | #define INF INT_MAX>>1
      |             ^~~~~~~
a.cc:64:49: note: in expansion of macro 'INF'
   64 |                                         if(d == INF){
      |                                                 ^~~
a.cc:5:13: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #define INF INT_MAX>>1
      |             ^~~~~~~
a.cc:64:49: note: in expansion of macro 'INF'
   64 |                                         if(d == INF){
      |                                                 ^~~
a.cc:5:13: error: 'INT_MAX' was not declared in this scope
    5 | #define INF INT_MAX>>1
      |             ^~~~~~~
a.cc:80:40: note: in expansion of macro 'INF'
   80 |                 fill(ans[0], ans[100], INF);
      |                                        ^~~
a.cc:5:13: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #define INF INT_MAX>>1
      |             ^~~~~~~
a.cc:80:40: note: in expansion of macro 'INF'
   80 |                 fill(ans[0], ans[100], INF);
      |                                        ^~~