Language: C++

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

const int INF = 1 << 25;
int cost[100][100], time[100][100];

int main() {
	int n, m, query;

	while (cin >> n >> m , n) {
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m; j++) {
				cost[i][j] = (i == j) ? 0 : INF;
				time[i][j] = (i == j) ? 0 : INF;
			}
		}

		while (n--) {
			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 i = 0; i < m; i++) {
				for (int j = 0; j < m; j++) {
					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]);
				}
			}
		}

		cin >> query;
		while (query--) {
			int p, q, r;
			cin >> p >> q >> r;
			if (r == 0) {
				cout << cost[p - 1][q - 1] << endl;
			}
			else {
				cout << time[p - 1][q - 1] << endl;
			}
		}
	}
}

Compiler output:
a.cc:6:34: error: 'int time [100][100]' redeclared as different kind of entity
    6 | int cost[100][100], time[100][100];
      |                                  ^
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:1:
/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:15:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   15 |                                 time[i][j] = (i == j) ? 0 : INF;
      |                                       ^
a.cc:15:42: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   15 |                                 time[i][j] = (i == j) ? 0 : INF;
      |                                          ^
a.cc:15:44: error: assignment of read-only location '*(time + (((sizetype)i) + ((sizetype)j)))'
   15 |                                 time[i][j] = (i == j) ? 0 : INF;
      |                                 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:23:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   23 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                   ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:23:42: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   23 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                          ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:23:56: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   23 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                                        ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:23:63: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   23 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                                               ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:23:65: error: assignment of read-only location '*(time + ((((sizetype)b) + ((sizetype)a)) + 18446744073709551614))'
   23 |                         time[a - 1][b - 1] = time[b - 1][a - 1] = t;
      |                                              ~~~~~~~~~~~~~~~~~~~^~~
a.cc:30:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                               ^
a.cc:30:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                  ^
a.cc:30:64: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                ^
a.cc:30:67: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                   ^
a.cc:30:76: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                            ^
a.cc:30:79: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                               ^
a.cc:30:89: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                                         ^
a.cc:30:92: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |                                         time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
      |                                                                                            ^
a.cc:30: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+'
   30 |                                         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:43:51: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   43 |                                 cout << time[p - 1][q - 1] << endl;
      |                                                   ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:43:58: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   43 |                                 cout << time[p - 1][q - 1] << endl;
      |                                                          ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]