Language: C++

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
static const int INF = 1LL<<61;

static const int MAX_N = 5005;

struct S {
  int to, c, r;
  S(int p1, int p2, int p3) {
    to = p1;
    c = p2;
    r = p3;
  }
};

int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
vector<pii> G[MAX_N];
vector<int> tg[MAX_N];

void dijkstra() {
  fill(d, d + MAX_N, INF);
  d[1] = 0;
  priority_queue<pii, vector<pii>, greater<pii>> q;
  q.push(pii(0, 1));

  while (q.size()) {
    pii p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;

    for (int i = 0; i < G[v].size(); ++i) {
      pii e = G[v][i];

      if (d[e.first] < e.second + p.first) continue;

      d[e.first] = e.second + p.first;
      q.push(pii(d[e.first], e.first));
    }
  }

  cout << d[n] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> C[i] >> R[i];
  }

  for (int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;
    tg[a].PB(b);
    tg[b].PB(a);
  }

  for (int i = 1; i <= n; ++i) {
      memset(visit, 0, sizeof(visit));
      visit[i] = true;
      queue<S> q;
      for (int j = 0; j < tg[i].size(); ++j) {
        q.push(S(tg[i][j], C[i], R[i]));
      }

      while (q.size()) {
        S s = q.front();
        q.pop();
        int v = s.to;
        if (visit[v] || s.r == 0) continue;
        G[i].PB(pii(v, s.c));
        visit[v] = true;

        for (int j = 0; j < tg[v].size(); ++j) {
          q.push(S(tg[v][j], s.c, s.r - 1));
        }
      }
  }

  dijkstra();

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:69:14: error: reference to 'visit' is ambiguous
   69 |       memset(visit, 0, sizeof(visit));
      |              ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:23:41: note:                 'long long int visit [5005]'
   23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
      |                                         ^~~~~
a.cc:69:31: error: reference to 'visit' is ambiguous
   69 |       memset(visit, 0, sizeof(visit));
      |                               ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:23:41: note:                 'long long int visit [5005]'
   23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
      |                                         ^~~~~
a.cc:70:7: error: reference to 'visit' is ambiguous
   70 |       visit[i] = true;
      |       ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:23:41: note:                 'long long int visit [5005]'
   23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
      |                                         ^~~~~
a.cc:80:13: error: reference to 'visit' is ambiguous
   80 |         if (visit[v] || s.r == 0) continue;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:23:41: note:                 'long long int visit [5005]'
   23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
      |                                         ^~~~~
a.cc:82:9: error: reference to 'visit' is ambiguous
   82 |         visit[v] = true;
      |         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:23:41: note:                 'long long int visit [5005]'
   23 | int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
      |                                         ^~~~~