Language: C++

#define _USE_MATH_DEFINES
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#define INF 10000000
using namespace std;
typedef long long ll;

int cost[110][110];
int time[110][110];

int main(void)
{
	while (1) {
		int n, m;
		cin >> n >> m;

		if (n == 0 && m == 0)break;

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m; j++) {
				if (i == j) {
					cost[i][j] = 0;
					time[i][j] = 0;
				}
				else {
					cost[i][j] = INF;
					time[i][j] = INF;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			cost[a - 1][b - 1] = cost[b - 1][a - 1] = c;
			time[a - 1][b - 1] = time[b - 1][a - 1] = t;
		}

		for (int k = 0; k < m; k++) {
			for (int j = 0; j < m; j++) {
				for (int i = 0; i < m; i++) {
					cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
					time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
				}
			}
		}
		int k;
		cin >> k;
		for (int i = 0; i < k; i++) {
			int p, q, r;
			cin >> p >> q >> r;
			if (r == 0)
				cout << cost[p - 1][q - 1] << endl;
			else if (r == 1)
				cout << time[p - 1][q - 1] << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc:18:18: error: 'int time [110][110]' redeclared as different kind of entity
   18 | int time[110][110];
      |                  ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:3:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:32:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   32 |                                         time[i][j] = 0;
      |                                               ^
a.cc:32:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   32 |                                         time[i][j] = 0;
      |                                                  ^
a.cc:32:52: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))'
   32 |                                         time[i][j] = 0;
      |                                         ~~~~~~~~~~~^~~
a.cc:36:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   36 |                                         time[i][j] = INF;
      |                                               ^
a.cc:36:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   36 |                                         time[i][j] = INF;
      |                                                  ^
a.cc:36:52: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))'
   36 |                                         time[i][j] = INF;
      |                                                    ^
a.cc:45:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                   ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:45:42: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                          ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:45:56: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                                        ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:45:63: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                                               ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:45:65: error: assignment of read-only location '*(time + ((((sizetype)b) + ((sizetype)a)) + 18446744073709551614))'
   45 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                              ~~~~~~~~~~~~~~~~~~~^~~
a.cc:52:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                               ^
a.cc:52:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                  ^
a.cc:52:64: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                ^
a.cc:52:67: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                   ^
a.cc:52:76: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                            ^
a.cc:52:79: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                               ^
a.cc:52:89: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                                         ^
a.cc:52:92: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                                            ^
a.cc:52:81: error: invalid operands of types 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} and 'time_t(time_t*) noexcept' {aka 'long int(long int*) noexcept'} to binary 'operator+'
   52 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                      ~~~~~~~~~~ ^ ~~~~~~~~~~
      |                                                                               |            |
      |                                                                               |            time_t(time_t*) noexcept {aka long int(long int*) noexcept}
      |                                                                               time_t(time_t*) noexcept {aka long int(long int*) noexcept}
a.cc:64:51: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   64 |                                 cout << time[p - 1][q - 1] << endl;
      |                                                   ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:64:58: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   64 |                                 cout << time[p - 1][q - 1] << endl;
      |                                                          ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]