Submission #889539

# Submission time Handle Problem Language Result Execution time Memory
889539 2023-12-20T00:44:47 Z dwuy Ferries (NOI13_ferries) C++14
40 / 40
169 ms 22532 KB
/// dwuy: _,\,,,_\,__,\,,_
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK ""
#define int long long

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 100005;

int n, m;
int d[MX];
vector<int> G[MX];
priority_queue<int> cost[MX];

void nhap(){
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        G[v].push_back(u);
        cost[u].push(c);
    }
}

void solve(){
    priority_queue<pii, vector<pii>, greater<pii>> Q;
    memset(d, 0x3f, sizeof d);
    d[n] = 0;
    Q.push({0, n});
    bitset<MX> vist = 0;
    while(Q.size()){
        int du, u; tie(du, u) = Q.top();
        Q.pop();
        if(vist[u]) continue;
        vist[u] = 1;
        for(int v: G[u]){
            int c = cost[v].top(); cost[v].pop();
            if(d[v] > d[u] + c){
                d[v] = d[u] + c;
                Q.push({d[v], v});
            }
        }
    }
    cout << d[1];
}

int32_t main(){
    fastIO;
    //file(TASK);

    nhap();
    solve();

    return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 3 ms 6748 KB Output is correct
3 Correct 8 ms 7924 KB Output is correct
4 Correct 79 ms 16572 KB Output is correct
5 Correct 75 ms 16572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 3 ms 6812 KB Output is correct
3 Correct 8 ms 7904 KB Output is correct
4 Correct 35 ms 11600 KB Output is correct
5 Correct 65 ms 13520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 7512 KB Output is correct
2 Correct 11 ms 8280 KB Output is correct
3 Correct 117 ms 21392 KB Output is correct
4 Correct 146 ms 21708 KB Output is correct
5 Correct 130 ms 20944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 117 ms 16452 KB Output is correct
2 Correct 145 ms 21352 KB Output is correct
3 Correct 164 ms 22464 KB Output is correct
4 Correct 169 ms 22496 KB Output is correct
5 Correct 144 ms 22532 KB Output is correct