Language: C++

#include<iostream>
#include<string.h>
using namespace std;
int kingaku(void);
int saitan(void);
#define WHITE 0
#define GLAY 1
#define BLACK 2
#define INF 9999
int n;	//	??????????????±?????°
int m;	//	?§??????°
int p;	//	????????°
int q;	//	??°?????°
int minv;
int cost[101][101];
int time[101][101];
int dd[101];
int main()
{
	int a,b,c,t,k,r;
	while(1){
		memset(cost,INF,sizeof(cost));
		memset(time,INF,sizeof(time));
		cin >> n >> m;
		if(n == 0 && m == 0) break;
		for(int i=0;i<n;i++){
			cin >> a >> b >> c >>t;
			cost[a][b] = cost[b][a] = c;
		time[a][b] = time[b][a] = t;
		}
		cin >> k;
		for(int i=0;i<k;i++){
			cin >> p >> q >> r;
			if(r == 0)
				cout << kingaku() << endl;
			else if(r == 1)
				cout << saitan() << endl;
			//for(int i=1;i<=m;i++)
			//	cout << i << " " << dd[i] << endl;
		}
	}
	return 0;
}

int kingaku()
{
	int u;
	int color[101];
	memset(dd,INF,sizeof(dd));
	memset(color,WHITE,sizeof(color));
	dd[p] = 0;
	color[p] = GLAY;
	while(1){
		u = -1;
		minv = INF;
		for(int i=1;i<=m;i++){
			if(minv > dd[i] && color[i] != BLACK){
				minv = dd[i];
				u = i;
			}
		}
		if(u==-1) break;
		color[u] = BLACK;
		for(int i=1;i<=m;i++){
			if(cost[u][i] != INF && color[i] != BLACK){
				if(dd[i] > dd[u] + cost[u][i])	//
					     //1?§?     1?§???¨??\?????????????§?
					dd[i] = dd[u] + cost[u][i];
			}
		}
	}
	return dd[q];
}

int saitan()
{
	int u;
	int color[101];
	memset(dd,INF,sizeof(dd));
	memset(color,WHITE,sizeof(color));
	dd[p] = 0;
	color[p] = GLAY;
	while(1){
		u = -1;
		minv = INF;
		for(int i=1;i<=m;i++){
			if(minv > dd[i] && color[i] != BLACK){
				minv = dd[i];
				u = i;
			}
		}
		if(u==-1) break;
		color[u] = BLACK;
		for(int i=1;i<=m;i++){
			if(time[u][i] != INF && color[i] != BLACK){
				if(dd[i] > dd[u] + time[u][i])
					dd[i] = dd[u] + time[u][i];
			}
		}
	}
	return dd[q];
}

Compiler output:
a.cc:16:18: error: 'int time [101][101]' redeclared as different kind of entity
   16 | int time[101][101];
      |                  ^
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:23:40: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   23 |                 memset(time,INF,sizeof(time));
      |                                       ~^~~~~
a.cc:23:24: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'void*' [-fpermissive]
   23 |                 memset(time,INF,sizeof(time));
      |                        ^~~~
      |                        |
      |                        time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}
In file included from a.cc:2:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
a.cc:29:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |                 time[a][b] = time[b][a] = t;
      |                       ^
a.cc:29:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |                 time[a][b] = time[b][a] = t;
      |                          ^
a.cc:29:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |                 time[a][b] = time[b][a] = t;
      |                                    ^
a.cc:29:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |                 time[a][b] = time[b][a] = t;
      |                                       ^
a.cc:29:41: error: assignment of read-only location '*(time + (((sizetype)b) + ((sizetype)a)))'
   29 |                 time[a][b] = time[b][a] = t;
      |                              ~~~~~~~~~~~^~~
a.cc: In function 'int saitan()':
a.cc:95:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   95 |                         if(time[u][i] != INF && color[i] != BLACK){
      |                                  ^
a.cc:95:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   95 |                         if(time[u][i] != INF && color[i] != BLACK){
      |                                     ^
a.cc:95:39: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   95 |                         if(time[u][i] != INF && color[i] != BLACK){
      |                                       ^
a.cc:96:58: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   96 |                                 if(dd[i] > dd[u] + time[u][i])
      |                                                          ^
a.cc:96:61: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   96 |                                 if(dd[i] > dd[u] + time[u][i])
      |                                                             ^
a.cc:96:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   96 |                                 if(dd[i] > dd[u] + time[u][i])
      |                                            ~~~~~~^~~~~~~~~~~~
a.cc:96:42: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   96 |                                 if(dd[i] > dd[u] + time[u][i])
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~
a.cc:97:63: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   97 |                                         dd[i] = dd[u] + time[u][i];
      |                                                               ^
a.cc:97:66: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   97 |                                         dd[i] = dd[u] + time[u][i];
      |                                                                  ^
a.cc:97:55: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   97 |                                         dd[i] = dd[u] + time[u][i];
      |                                                 ~~~~~~^~~~~~~~~~~~
a.cc:97:55: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
   97 |                                         dd[i] = dd[u] + time[u][i];
      |                                                 ~~~~~~^~~~~~~~~~~~
      |                                                       |
      |                                                       time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}