제출 #1067745

#제출 시각아이디문제언어결과실행 시간메모리
1067745dwuyCommuter Pass (JOI18_commuter_pass)C++14
컴파일 에러
0 ms0 KiB
include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> pii;

const int MX = 200005;
int n, m, S, T, U, V;
vector<pii> G[MX];
int dS[MX];
int dT[MX];
int dU[MX];
int dV[MX];
int f1[MX];
int f2[MX];

void dijkstra(int X, int *d){
    for(int i=0; i<=n; i++) d[i] = 1e18;
    d[X] = 0;
    priority_queue<pii> Q;
    Q.push({0, X});
    while(Q.size()){
        int du, u;
        tie(du, u) = Q.top();
        Q.pop();
        du = -du;
        if(du != d[u]) continue;
        for(pii edge: G[u]){
            int v, c;
            tie(v, c) = edge;
            if(d[v] > du + c){
                d[v] = du + c;
                Q.push({-d[v], v});
            }
        }
    }
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    //freopen("xebuyt.inp","r",stdin);
    //freopen("xebuyt.out","w",stdout);

    cin >> n >> m;
    cin >> S >> T;
    cin >> U >> V;
    for(int i=1; i<=m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        G[u].push_back({v, c});
        G[v].push_back({u, c});
    }

    dijkstra(S, dS);
    dijkstra(T, dT);
    dijkstra(U, dU);
    dijkstra(V, dV);

    vector<int> vt(n);
    for(int i=0; i<n; i++) vt[i] = i + 1;
    sort(vt.begin(), vt.end(), [&](const int &a, const int &b) -> bool {return dS[a] > dS[b];});


    memset(f1, 0x3f, sizeof f1);
    memset(f2, 0x3f, sizeof f2);
    f1[T] = dU[T];
    f2[T] = dV[T];
    int ans = 1e18;
    for(int u: vt) if(dS[u] + dT[u] == dS[T]){
        for(pii edge: G[u]){
            int v, c;
            tie(v, c) = edge;
            if(dS[v] + dT[v] == dS[T] && dS[v] > dS[u]){
                f1[u] = min(f1[v], dU[u]);
                f2[u] = min(f2[v], dV[u]);
            }
        }
        ans = min({ans, f1[u] + dV[u], f2[u] + dU[u]});
    }

    cout << ans;

    return 0;
}

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

commuter_pass.cpp:43:2: error: extended character   is not valid in an identifier
   43 |     //freopen("xebuyt.inp","r",stdin);
      |  ^
commuter_pass.cpp:43:5: error: extended character   is not valid in an identifier
   43 |     //freopen("xebuyt.inp","r",stdin);
      |    ^
commuter_pass.cpp:44:2: error: extended character   is not valid in an identifier
   44 |     //freopen("xebuyt.out","w",stdout);
      |  ^
commuter_pass.cpp:44:5: error: extended character   is not valid in an identifier
   44 |     //freopen("xebuyt.out","w",stdout);
      |    ^
commuter_pass.cpp:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
commuter_pass.cpp:4:9: error: 'pair' does not name a type
    4 | typedef pair<int, int> pii;
      |         ^~~~
commuter_pass.cpp:8:1: error: 'vector' does not name a type
    8 | vector<pii> G[MX];
      | ^~~~~~
commuter_pass.cpp: In function 'void dijkstra(long long int, long long int*)':
commuter_pass.cpp:19:5: error: 'priority_queue' was not declared in this scope
   19 |     priority_queue<pii> Q;
      |     ^~~~~~~~~~~~~~
commuter_pass.cpp:19:20: error: 'pii' was not declared in this scope
   19 |     priority_queue<pii> Q;
      |                    ^~~
commuter_pass.cpp:19:25: error: 'Q' was not declared in this scope
   19 |     priority_queue<pii> Q;
      |                         ^
commuter_pass.cpp:23:9: error: 'tie' was not declared in this scope
   23 |         tie(du, u) = Q.top();
      |         ^~~
commuter_pass.cpp:27:16: error: expected ';' before 'edge'
   27 |         for(pii edge: G[u]){
      |                ^~~~~
      |                ;
commuter_pass.cpp:35:5: error: expected primary-expression before '}' token
   35 |     }
      |     ^
commuter_pass.cpp:34:10: error: expected ';' before '}' token
   34 |         }
      |          ^
      |          ;
   35 |     }
      |     ~     
commuter_pass.cpp:35:5: error: expected primary-expression before '}' token
   35 |     }
      |     ^
commuter_pass.cpp:34:10: error: expected ')' before '}' token
   34 |         }
      |          ^
      |          )
   35 |     }
      |     ~     
commuter_pass.cpp:27:12: note: to match this '('
   27 |         for(pii edge: G[u]){
      |            ^
commuter_pass.cpp:35:5: error: expected primary-expression before '}' token
   35 |     }
      |     ^
commuter_pass.cpp: At global scope:
commuter_pass.cpp:39:1: error: 'int32_t' does not name a type
   39 | int32_t main(){
      | ^~~~~~~