Language: C++

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