답안 #611878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
611878 2022-07-29T08:16:24 Z jame0313 Price List (POI13_cen) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;
// and so on
vector<vector<int> > mp;
bool vis[100001];
int vis2[100001];
bool vis3[100001];
ll dist[100001];
const ll INF = 1LL << 60;
priority_queue<pll, vector<pll>, greater<pll> > pq;
int N, M, S, A, B;
void dijkstra() {
    for (int i = 1; i <= N; i++) dist[i] = INF;
    dist[S] = 0;
    pq.push({dist[S], S});
    while (!pq.empty()) {
        auto [d, x] = pq.top();
        pq.pop();
        if (vis[x]) continue;
        vis[x] = true;
        vis2[x] = x;
        for (auto nx : mp[x]) {
            vis2[nx] = x;
            if (!vis[nx] && dist[nx] > dist[x] + A) {
                dist[nx] = dist[x] + A;
                pq.push({dist[nx], nx});
            }
            
        }
        for (auto nx : mp[x]) {
            if(vis3[nx]) continue;
            vis3[nx] = true;5 5 1 3 2
1 2
2 3
3 4
4 5
3 1
            for (auto nnx : mp[nx]) {
                if (vis2[nnx] == x) continue;
                vis2[nnx] = x;
                if (!vis[nnx] && dist[nnx] > dist[x] + B) {
                    dist[nnx] = dist[x] + B;
                    pq.push({dist[nnx], nnx});
                }
            }
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M >> S >> A >> B;
    mp.resize(N + 1);
    vector<int> costs;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        mp[a].push_back(b);
        mp[b].push_back(a);
    }

    dijkstra();
    for (int i = 1; i <= N; i++) cout << dist[i] << '\n';
}

Compilation message

cen.cpp: In function 'void dijkstra()':
cen.cpp:36:30: error: expected ';' before numeric constant
   36 |             vis3[nx] = true;5 5 1 3 2
      |                              ^~
      |                              ;
cen.cpp:36:29: warning: statement has no effect [-Wunused-value]
   36 |             vis3[nx] = true;5 5 1 3 2
      |                             ^