제출 #761949

#제출 시각아이디문제언어결과실행 시간메모리
761949hgmhc날다람쥐 (JOI14_ho_t4)C++17
25 / 100
131 ms17412 KiB
#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]+2*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]);
}

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

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...