제출 #1346890

#제출 시각아이디문제언어결과실행 시간메모리
1346890i_love_springRobot (JOI21_ho_t4)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long 
const int inf = 2e9;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ar<int, 4>> edges(m);
    vector<vector<ar<int, 2>>> g(n);
    for (int i = 0; i < m;i++) {
        int u, v, c, w;
        cin >> u >> v >> c >> w;
        --u, --v;
        edges[i] = {u, v, c, w};
        g[u].push_back({v, i});
        g[v].push_back({u, i});
    }

    queue<int> q;
    vector<int> dist(n, inf);
    d[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto [v, id] : g[u])
            if (d[v] > d[u] + 1)
                d[v] = d[u] + 1, q.push(v); 
    }

    cout << (d[n - 1] == inf ? -1 : d[n - 1]);
}

int32_t main() { 

#ifdef Behruz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif 

    ios :: sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    solve();

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void solve()':
Main.cpp:25:5: error: 'd' was not declared in this scope
   25 |     d[0] = 0;
      |     ^