Submission #1170580

#TimeUsernameProblemLanguageResultExecution timeMemory
1170580BzslayedConstruction Project 2 (JOI24_ho_t2)C++20
0 / 100
4 ms5704 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define ll long long #define ull unsigned long long #define llll __int128 #define ld long double #define pll pair<ll, ll> #define pii pair<int, int> #define coutpair(p) cout << p.first << " " << p.second << "|" template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; const ll INF = 1e16; ll n, m; vector<pll> adj[200005]; ll dist[2][200005]; bool vis[2][200005]; void dijkstra(ll idx, ll st){ priority_queue<pll, vector<pll>, greater<pll>> pq; for (int i=0; i<=n; i++){ dist[idx][i] = INF; vis[idx][i] = false; } dist[idx][st] = 0; vis[idx][st] = false; pq.push({0, st}); while (!pq.empty()){ ll weight = pq.top().first, cur = pq.top().second; pq.pop(); if (dist[idx][cur] < weight) continue; vis[idx][cur] = true; for (auto [w, node]: adj[cur]){ if (dist[idx][node] > dist[idx][cur]+w && !vis[idx][node]){ dist[idx][node] = dist[idx][cur]+w; pq.push({dist[idx][node], node}); } } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; ll s, t, l, k; cin >> s >> t >> l >> k; for (int i=0; i<m; i++){ ll a, b, c; cin >> a >> b >> c; adj[a].push_back({c, b}); adj[b].push_back({c, a}); } dijkstra(0, s); dijkstra(1, t); gp_hash_table<ll, ll> val; ordered_multiset<ll> ms; for (int i=1; i<=n; i++){ val[i] = dist[1][i]; ms.insert(dist[1][i]); } // cout << "\n"; // for (int i=1; i<=n; i++) cout << dist[0][i] << " "; // cout << "\n"; // for (int i=1; i<=n; i++) cout << dist[1][i] << " "; // cout << "\n"; ll ans = 0; for (int i=1; i<=n; i++){ ms.erase(ms.find_by_order(ms.order_of_key(val[i]))); if (i != 1) ms.insert(val[i-1]); //for (auto it : ms) cout << it << " "; //cout << "\n"; ll req = k-l-dist[0][i]; ll res = ms.order_of_key(req+1); //cout << res << " "; //cout << "\n"; ans += res; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...