Submission #761948

# Submission time Handle Problem Language Result Execution time Memory
761948 2023-06-20T12:27:46 Z hgmhc None (JOI14_ho_t4) C++17
0 / 100
136 ms 14008 KB
#include <bits/stdc++.h>
#define rep(i,a,b) for (auto i = (a); i <= (b); ++i)
#define Mup(x,y) x = max(x,y)
#define mup(x,y) x = min(x,y)
#define all(x) begin(x),end(x)
#define per(i,a,b) for (auto i = (b); i >= (a); --i)
using namespace std;
using ll = long long;
using ii = pair<int,int>;
#define dbg(...) fprintf(stderr,__VA_ARGS__)

const ll INF = 1e18;
const int N = 1e5+3;
int n, m, x, h[N];
vector<ii> adj[N];
ll k[N];

int main() {
    scanf("%d%d%d", &n, &m, &x);
    assert(!x);
    rep(i,1,n) scanf("%d", &h[i]);
    rep(i,1,m) {
        int u, v, t;
        scanf("%d%d%d", &u, &v, &t);
        adj[u].push_back({v,t});
        adj[v].push_back({u,t});
    }
    fill(k,k+N,INF);
    priority_queue<pair<ll,int>> pq;
    k[1] = 0, pq.push({0,1});
    while (not empty(pq)) {
        auto [d,a] = pq.top(); pq.pop(), d=-d;
        if (k[a] < d) continue;
        for (auto [b,t] : adj[a]) {
            if (h[a] > t and k[b] > k[a]+t) {
                k[b] = k[a]+2*t;
                pq.push({-k[b],b});
            }
        }
    }
    if (h[n]+k[n] >= INF) puts("-1");
    else printf("%lld", h[n]+k[n]);
    // rep(i,1,n) dbg("%lld ", k[i]);
}

Compilation message

2014_ho_t4.cpp: In function 'int main()':
2014_ho_t4.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d%d", &n, &m, &x);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
2014_ho_t4.cpp:21:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     rep(i,1,n) scanf("%d", &h[i]);
      |                ~~~~~^~~~~~~~~~~~~
2014_ho_t4.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%d%d%d", &u, &v, &t);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 5204 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 117 ms 12880 KB Output is correct
2 Correct 104 ms 14008 KB Output is correct
3 Correct 64 ms 8572 KB Output is correct
4 Correct 136 ms 13916 KB Output is correct
5 Correct 93 ms 13548 KB Output is correct
6 Correct 6 ms 3796 KB Output is correct
7 Correct 97 ms 12516 KB Output is correct
8 Correct 112 ms 12872 KB Output is correct
9 Incorrect 94 ms 11980 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 5204 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -