답안 #1006841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006841 2024-06-24T09:15:01 Z overwatch9 Toll (BOI17_toll) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 50001;
vector <pair <int, int>> adj[maxn];
ll dis[maxn];
int processed[maxn];
queue <int> modified;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int K, N, M, O;
    cin >> K >> N >> M >> O;
    for (int i = 0; i < M; i++) {
        int a, b, t;
        cin >> a >> b >> t;
        adj[a].push_back({b, t});
    }
    for (int o = 1; o <= O; o++) {
        int st, ed;
        cin >> st >> ed;
        dis[st] = 0;
        priority_queue <pair <ll, int>> pq;
        modified.push(st);
        pq.push({0, st});
        while (!pq.empty()) {
            int s = pq.top().second;
            pq.pop();
            if (processed[s] == o)
                continue;
            processed[s] = o;
            for (auto i : adj[s]) {
                if (dis[i.first] > dis[s] + i.second) {
                    if (dis[i.first] == 1e18)
                        modified.push(i.first);
                    dis[i.first] = dis[s] + i.second;
                    pq.push({-dis[i.first], i.first});
                }
            }
        }
        if (dis[ed] == 1e18)
            dis[ed] = -1;
        cout << dis[ed] << '\n';
        while (!q.empty()) {
            dis[q.front()] = 1e18;
            q.pop();
        }
    }
}

Compilation message

toll.cpp: In function 'int main()':
toll.cpp:45:17: error: 'q' was not declared in this scope; did you mean 'pq'?
   45 |         while (!q.empty()) {
      |                 ^
      |                 pq