Language: C++

#include <cstdio>
#include <algorithm>

using namespace std;

#define chmin(a,b) a=min(a,b)
#define rep(i,x) for(int i=0;i<(x);++i)

const int inf = 1e9;

int N, M;
int mc[100][100], mt[100][100];

int main()
{
	while (scanf("%d %d", &N, &M), N || M) {
		fill(mc, mc[M], inf);
		fill(mt, mt[M], inf);

		rep(i, M) mc[i][i] = mt[i][i] = 0;

		rep(i, N) {
			int a, b, cost, time; scanf("%d %d %d %d", &a, &b, &cost, &time); a--; b--;
			mc[a][b] = mc[b][a] = cost;
			mt[a][b] = mt[b][a] = time;
		}

		rep(k, M) rep(i, M) rep(j, M) {
			chmin(mc[i][j], mc[i][k] + mc[j][k]);
			chmin(mt[i][j], mt[i][k] + mt[j][k]);
		}

		int K; scanf("%d", &K);
		rep(i, K) {
			int p, q, r; scanf("%d %d %d", &p, &q, &r); p--; q--;
			printf("%d\n", r == 0 ? mc[p][q] : mt[p][q]);
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: no matching function for call to 'fill(int [100][100], int [100], const int&)'
   17 |                 fill(mc, mc[M], inf);
      |                 ~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1022 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note:   template argument deduction/substitution failed:
a.cc:17:21: note:   deduced conflicting types for parameter '_ForwardIterator' ('int (*)[100]' and 'int*')
   17 |                 fill(mc, mc[M], inf);
      |                 ~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note:   candidate expects 4 arguments, 3 provided
a.cc:18:21: error: no matching function for call to 'fill(int [100][100], int [100], const int&)'
   18 |                 fill(mt, mt[M], inf);
      |                 ~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1022 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note:   template argument deduction/substitution failed:
a.cc:18:21: note:   deduced conflicting types for parameter '_ForwardIterator' ('int (*)[100]' and 'int*')
   18 |                 fill(mt, mt[M], inf);
      |                 ~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note:   candidate expects 4 arguments, 3 provided