Submission #948495

# Submission time Handle Problem Language Result Execution time Memory
948495 2024-03-18T07:05:16 Z phone64bit Commuter Pass (JOI18_commuter_pass) C++17
0 / 100
101 ms 16068 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int mxN = 1e5+10;

struct Q {
    int src; ll w;
    bool operator < (const Q&rhs) const {
        return w>rhs.w;
    }
};

struct path {
    int dest; ll w;
};

vector<path> edges[mxN];
ll dp[mxN], ans = 1e18;

priority_queue<Q> pq;

int main() {
    for(int i=0; i<mxN; i++) dp[i]=1e18;
    int n,m,s,t,u,v; scanf("%d%d%d%d%d%d", &n,&m,&s,&t,&u,&v);
    while(m--) {
        int u, v; ll w; scanf("%d%d%lld", &u, &v, &w);
        edges[u].push_back({v, w});
        edges[v].push_back({u, w});
    }
    dp[u] = 0;
    pq.push({u, 0});
    while(!pq.empty()) {
        auto [src, w] = pq.top();
        pq.pop();
        if(src==v) {
            ans=w;
            break;
        }
        for(auto v: edges[src]) {
            if(dp[v.dest]>w+v.w) {
                dp[v.dest]=w+v.w;
                pq.push({v.dest, dp[v.dest]});
            }
        }
    }
    printf("%lld", ans);
    return 0;
}

Compilation message

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:25:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     int n,m,s,t,u,v; scanf("%d%d%d%d%d%d", &n,&m,&s,&t,&u,&v);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:27:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         int u, v; ll w; scanf("%d%d%lld", &u, &v, &w);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 16068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 14496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 16068 KB Output isn't correct
2 Halted 0 ms 0 KB -