Submission #1057480

# Submission time Handle Problem Language Result Execution time Memory
1057480 2024-08-13T20:30:58 Z sammyuri Construction Project 2 (JOI24_ho_t2) C++17
0 / 100
3 ms 5468 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 2e5 + 5;

const ll INF = 1e18;
int n;
vector<pair<int, ll>> adj[MAXN];

void dijkstra(int startnode, vector<ll> &dist) {
    dist.clear(); dist.resize(n, INF);
    dist[startnode] = 0;
    priority_queue<pair<ll, int>> pq;
    pq.push({0, startnode});
    while (pq.size()) {
        pair<ll, int> cur = pq.top(); pq.pop();
        ll curdist = -cur.first;
        int curnode = cur.second;
        if (dist[curnode] != curdist)
            continue;
        for (auto a : adj[curnode]) {
            ll newdist = curdist + a.second;
            if (dist[a.first] > newdist) {
                dist[a.first] = newdist;
                pq.push({-newdist, a.first});
            }
        }
    }
}

int main() {
    int m; cin >> n >> m;
    int s, t; ll l, k; cin >> s >> t >> l >> k;
    s --; t --;
    while (m --) {
        int a, b; ll c; cin >> a >> b >> c;
        a --; b --;
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }
    vector<ll> dist_forwards, dist_backwards;
    dijkstra(s, dist_forwards);
    dijkstra(t, dist_backwards);
    ll ans = 0;
    ordered_set vals;
    for (int i = 0; i < n; i ++)
        vals.insert({dist_backwards[i], i});
    for (int i = 0; i < n; i ++) {
        vals.erase({dist_backwards[i], i});
        ll sofar = dist_forwards[i] + l;
        ll req = k - sofar;
        // cout << dist_backwards[i] << " " << sofar << " " <<  vals.order_of_key({req, 1e9}) << endl;
        ll cur = vals.order_of_key({req, 1e9});
        ans += cur;
        vals.insert({dist_backwards[i], i});
    }
    cout << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 3 ms 5464 KB Output is correct
6 Incorrect 3 ms 5468 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 5128 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Incorrect 1 ms 4956 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 5128 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Incorrect 1 ms 4956 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 3 ms 5464 KB Output is correct
6 Incorrect 3 ms 5468 KB Output isn't correct
7 Halted 0 ms 0 KB -