Language: C++

#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

struct edge { int to, cost, time; };
typedef pair<int, int> P;
vector<edge> G[105];
int n, m, k, cost[105], time[105];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> costque, timeque;
    fill(cost, cost + m + 1, INF);
    fill(time, time + m + 1, INF);
    cost[s] = 0;
    time[s] = 0;
    costque.push(P(s, 0));
    timeque.push(P(s, 0));

    while (!costque.empty()) {
        P p = costque.top();
        costque.pop();
        int v = p.first;
        if (cost[v] < p.second) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (cost[e.to] > cost[v] + e.cost) {
                cost[e.to] = cost[v] + e.cost;
                costque.push(P(e.to, cost[e.to]));
            }
        }
    }
    while (!timeque.empty()) {
        P p = timeque.top();
        timeque.pop();
        int v = p.first;
        if (time[v] < p.second) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (time[e.to] > time[v] + e.time) {
                time[e.to] = time[v] + e.time;
                timeque.push(P(e.to, time[e.to]));
            }
        }
    }
}

int main() {
    while (1) {
        cin >> n >> m;
        if (n == 0&&m == 0) break;
        for (int i = 0; i < n; i++) {
            int a, b, c, t;
            cin >> a >> b >> c >> t;
            edge tmp = { b,c,t };
            G[a].push_back(tmp);
        }
        cin >> k;
        for (int i = 0; i < k; i++) {
            int p, q, r;
            cin >> p >> q >> r;
            dijkstra(p);
            if (r == 0) cout << cost[q] << endl;
            else cout << time[q] << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc:25:33: error: 'int time [105]' redeclared as different kind of entity
   25 | int n, m, k, cost[105], time[105];
      |                                 ^
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 'void dijkstra(int)':
a.cc:30:21: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |     fill(time, time + m + 1, INF);
      |                ~~~~~^~~
a.cc:30:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   30 |     fill(time, time + m + 1, INF);
      |                ~~~~~~~~~^~~
a.cc:32:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   32 |     time[s] = 0;
      |           ^
a.cc:32:13: error: assignment of read-only location '*(time + ((sizetype)s))'
   32 |     time[s] = 0;
      |     ~~~~~~~~^~~
a.cc:53:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   53 |         if (time[v] < p.second) continue;
      |                   ^
a.cc:53:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   53 |         if (time[v] < p.second) continue;
      |             ~~~~~~~~^~~~~~~~~~
a.cc:56:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   56 |             if (time[e.to] > time[v] + e.time) {
      |                          ^
a.cc:56:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   56 |             if (time[e.to] > time[v] + e.time) {
      |                                    ^
a.cc:56:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   56 |             if (time[e.to] > time[v] + e.time) {
      |                              ~~~~~~~~^~~~~~~~
a.cc:57:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   57 |                 time[e.to] = time[v] + e.time;
      |                          ^
a.cc:57:36: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   57 |                 time[e.to] = time[v] + e.time;
      |                                    ^
a.cc:57:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   57 |                 time[e.to] = time[v] + e.time;
      |                              ~~~~~~~~^~~~~~~~
a.cc:57:28: error: assignment of read-only location '*(time + ((sizetype)e.edge::to))'
   57 |                 time[e.to] = time[v] + e.time;
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:58:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   58 |                 timeque.push(P(e.to, time[e.to]));
      |                                               ^
a.cc:58:48: error: no matching function for call to 'std::pair<int, int>::pair(int&, time_t (&)(time_t*) noexcept)'
   58 |                 timeque.push(P(e.to, time[e.to]));
      |                                                ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41:
/usr/include/c++/14/bits/stl_pair.h:913:28: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
  913 |         explicit constexpr pair(pair<_U1, _U2>&& __p)
      |                            ^~~~
/usr/include/c++/14/bits/stl_pair.h:913:28: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:902:19: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
  902 |         constexpr pair(pair<_U1, _U2>&& __p)
      |                   ^~~~
/usr/include/c++/14/bits/stl_pair.h:902:19: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:891:28: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && (! _ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
  891 |         explicit constexpr pair(_U1&& __x, _U2&& __y)
      |                            ^~~~
/usr/include/c++/14/bits/stl_pair.h:891:28: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:890:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
  890 |                          bool>::type=false>
      |                                      ^~~~~
/usr/include/c++/14/bits/stl_pair.h:881:19: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && _ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U2 = _U1; typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
  881 |         constexpr pair(_U1&& __x, _U2&& __y)
      |                   ^~~~
/usr/include/c++/14/bits/stl_pair.h:881:19: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:880:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
  880 |                          bool>::type=true>
      |                                      ^~~~
/usr/include/c++/14/bits/stl_pair.h:869:9: note: candidate: 'template<class _U2, typename std::enable_if<std::__and_<std::is_pointer<int>, std::__not_<std::is_reference<_Tp> >, std::is_constructible<int, _U1>, std::__not_<std::is_constructible<int, const _U1&> >, std::__not_<std::is_convertible<_Iter, int> > >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(__zero_as_null_pointer_constant, _U2&&, ...) [with typename std::enable_if<std::__and_<std::is_pointer<_Tp>, std::__not_<std::is_reference<_U1> >, std::is_constructible<_T2, _U2>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::__not_<std::is_convertible<_U2, _T2> > >::value, bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
  869 |         pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
      |         ^~~~
/usr/include/c++/14/bits/stl_pair.h:869:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:866:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
  866 |                              bool> = false>
      |                                      ^~~~~
/usr/include/c++/14/bits/stl_pair.h:856:9: note: candidate: 'template<class _U2, typename std::enable_if<std::__and_<std::is_pointer<int>, std::__not_<std::is_reference<_Tp> >, std::is_constructible<int, _U1>, std::__not_<std::is_constructible<int, const _U1&> >, std::is_convertible<_Iter, int> >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(__zero_as_null_pointer_constant, _U2&&, ...) [with typename std::enable_if<std::__and_<std::is_pointer<_Tp>, std::__not_<std::is_reference<_U1> >, std::is_constructible<_T2, _U2>, std::__not_<std::is_constructible<_T1, const _U1&> >, std::is_convertible<_U2, _T2> >::value, bool>::type <anonymous> = _U2; _T1 = int; _T2 = int]'
  856 |         pair(__zero_as_null_pointer_constant, _U2&& __y, ...)
      |         ^~~~
/usr/include/c++/14/bits/stl_pair.h:856:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h:853:38: error: no type named 'type' in 'struct std::enable_if<false, bool>'
  853 |                              bool> = true>
      |                                      ^~~~
/usr/include/c++/14/bits/stl_pair.h:843:9: note: candidate: 'template<class _U1, typename std::enable_if<std::__and_<std::__not_<std::is_reference<_Tp> >, std::is_pointer<int>, std::is_constructible<int, _U1>, std::__not_<std::is_constructible<int, const _U1&> >, std::__not_<std::is_convertible<_Iter, int> > >::value, bool>::type <anonymous> > constexpr std: