Language: C++

#include <iostream>
#include <queue>
using namespace std;

#define MAX_N 100
#define MAX_C 20
#define MAX_P 50
#define MAX_D 200
#define MAX_R 10001
#define INF 0xfffffff

int fare[MAX_C][MAX_R + MAX_D];
int p[MAX_C];
int q[MAX_C][MAX_P];
int r[MAX_C][MAX_P];
bool done[MAX_N][MAX_C][MAX_R];

class node {
	public:
	int cost, com, dist, sta;
	node(int c, int co, int dd, int s):cost(c), com(co), dist(dd), sta(s){};
};

bool operator> (const node& l, const node& r) {
	return l.cost > r.cost;
}

class edge {
	public:
	int to, dist, com;
	edge(int t, int d, int c):to(t), dist(d), com(c){};
};

vector<vector<edge> >es;

inline int calc_fare(int current_dist, int next_dist, int com) {
	return (fare[com][next_dist] - fare[com][current_dist]);
}

int dijkstra(int s, int g) {
	memset(done, false, sizeof(done));

	priority_queue<node, vector<node>, greater<node> > que;
	que.push(node(0, 0, 0, s));
	while(!que.empty()) {
		node u = que.top();
		que.pop();
	
		if(done[u.sta][u.com][u.dist])
			continue;
		
		if(u.sta == g)
			return u.cost;

		done[u.sta][u.com][u.dist] = true;
		
		for(int i=0; i<es[u.sta].size(); i++) {
			edge e = es[u.sta][i];
			int current_dist = (u.com == e.com ? u.dist : 0);

			int next_dist = current_dist + e.dist;
			int cost = u.cost + calc_fare(current_dist, next_dist, e.com);
			que.push(node(cost, e.com, min(next_dist, MAX_R-1), e.to));
		}
	}
	
	return -1;
}

int main() {
	cin.tie(false);
	ios::sync_with_stdio(false);

	int n, m, c, s, g;
	while(cin >> n >> m >> c >> s >> g, n) {		
		--s, --g;
		
		es.clear();
		es.resize(n);
		
		for(int i=0; i<m; i++) {
			int x, y, d, c_temp;
			cin >> x >> y >> d >> c_temp;
			--x; --y; --c_temp;
			es[x].push_back(edge(y, d, c_temp));
			es[y].push_back(edge(x, d, c_temp));
		}
		
		for(int i=0; i<c; i++)
			cin >> p[i];
			
		memset(q, 0, sizeof(q));
		for(int i=0; i<c; i++) {
			for(int j=0; j<p[i]-1; j++)
				cin >> q[i][j];
			q[i][p[i]] = INF;

			for(int j=0; j<p[i]; j++)
				cin >> r[i][j];

			fare[i][0] = 0;
			int index = 0;
			for(int j=1; j<MAX_R + MAX_D; j++) {
				fare[i][j] = fare[i][j-1] + r[i][index];
				if(j == q[i][index])
					++index;
			}
		}
		cout << dijkstra(s, g) << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int dijkstra(int, int)':
a.cc:41:9: error: 'memset' was not declared in this scope
   41 |         memset(done, false, sizeof(done));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <queue>
  +++ |+#include <cstring>
    3 | using namespace std;
a.cc: In function 'int main()':
a.cc:71:16: error: no matching function for call to 'std::basic_istream<char>::tie(bool)'
   71 |         cin.tie(false);
      |         ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]'
  299 |       tie() const
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_ios.h:311:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:311:43: note:   no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
a.cc:92:17: error: 'memset' was not declared in this scope
   92 |                 memset(q, 0, sizeof(q));
      |                 ^~~~~~
a.cc:92:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'