Language: C++

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0200

/* http://www.deqnotes.net/acmicpc/dijkstra/
9 6
1 2 5 0
1 3 4 0
1 4 2 0
2 3 2 0
3 4 3 0
2 6 6 0
3 5 2 0
5 6 4 0
4 5 6 0
1
1 6 0
0 0

*/

#include <cstdio>
#include <climits>
#include <cstring>

#define STATION_MAX 101

//#define dprintf(arg1, ... ) printf( arg1, __VA_ARGS__)
#define dprintf(arg1, ... ) 

/*
typedef struct {
	
} LINE;
*/


int main(void) {

	while(1) {
		int line_cnt, stat_cnt;
		scanf("%d %d\n", &line_cnt, &stat_cnt);
		if ( line_cnt==0 && stat_cnt== 0 ) { break; }
		
		int line_cost[2][STATION_MAX][STATION_MAX];
		memset( line_cost, -1, sizeof(int)*2*STATION_MAX*STATION_MAX );
		
		int a; int b; int fee; int time;
		for( int i=0; i<line_cnt; i++ ) {
			scanf("%d %d %d %d\n", &a, &b, &fee, &time );
			line_cost[0][a][b] = line_cost[0][b][a] = fee;
			line_cost[1][a][b] = line_cost[1][b][a] = time;
		}
		
		int query_cnt;
		scanf("%d\n", &query_cnt );
		
		for( int i=0; i<query_cnt; i++ ) {
			int start, end, type;
			
			scanf("%d %d %d\n", &start, &end, &type );
			
			int stat_cost[STATION_MAX];
			bool stat_flag[STATION_MAX];
			memset( stat_cost, -1, sizeof(int)*STATION_MAX );
			memset( stat_flag, false, sizeof(bool)*STATION_MAX );
			
			stat_cost[start] = 0;
			
			while(1) {
				int minstat = -1;
				int minval=INT_MAX;
				for ( int i=1; i<stat_cnt+1; i++ ) {
					if ( stat_cost[i] == -1 ) { continue; }
					if ( stat_flag[i] == true ) { continue; }
					if ( stat_cost[i] < minval ) { minstat = i; minval = stat_cost[i]; }
				}
				if ( minstat == -1 ) { break; }
				dprintf("minstat: %d stat_cost=%d\n", minstat, stat_cost[minstat]);
				
				stat_flag[minstat] = true;
				
				//check_tonari
				for ( int i=1; i<stat_cnt+1; i++ ) {
				if ( lcost[nowstat][i] == -1 ) { continue; }
					if ( stat_cost[i] == -1 ||  stat_cost[i] > stat_cost[nowstat] + lcost[nowstat][i] ) {
						dprintf( "Refresh stat_cost[%d]:  %d (old: %d)\n", i, stat_cost[nowstat] + lcost[nowstat][i], stat_cost[i]);
						stat_cost[i] = stat_cost[nowstat] + lcost[nowstat][i];
					}
				}
			}
			
			printf("%d\n", stat_cost[end]);
		}
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:83:38: error: 'lcost' was not declared in this scope
   83 |                                 if ( lcost[nowstat][i] == -1 ) { continue; }
      |                                      ^~~~~
a.cc:83:44: error: 'nowstat' was not declared in this scope
   83 |                                 if ( lcost[nowstat][i] == -1 ) { continue; }
      |                                            ^~~~~~~
a.cc:84:94: error: 'nowstat' was not declared in this scope
   84 |                                         if ( stat_cost[i] == -1 ||  stat_cost[i] > stat_cost[nowstat] + lcost[nowstat][i] ) {
      |                                                                                              ^~~~~~~
a.cc:84:105: error: 'lcost' was not declared in this scope
   84 |                                         if ( stat_cost[i] == -1 ||  stat_cost[i] > stat_cost[nowstat] + lcost[nowstat][i] ) {
      |                                                                                                         ^~~~~