# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1123059 | ro9669 | Construction Project 2 (JOI24_ho_t2) | C++20 | 2095 ms | 5348 KiB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;
const int maxN = int(2e5)+7;
int n , m , s , t , l; ll k;
vector<ii> g[maxN];
ll d[maxN];
void dijkstra(){
for (int i = 1 ; i <= n ; i++) d[i] = k + 1;
d[s] = 0;
priority_queue<lli , vector<lli> , greater<lli>> pq;
pq.push({d[s] , s});
while (pq.empty() == 0){
ii it = pq.top(); pq.pop();
int u = it.se;
if (d[u] != it.fi) continue;
for (ii e : g[u]){
int v = e.fi;
int w = e.se;
if (d[v] > it.fi + 1ll * w){
d[v] = it.fi + 1ll * w;
pq.push({d[v] , v});
}
}
}
}
void solve(){
cin >> n >> m >> s >> t >> l >> k;
for (int i = 1 ; i <= m ; i++){
int u , v , w;
cin >> u >> v >> w;
g[u].push_back({v , w});
g[v].push_back({u , w});
}
int ans = 0;
for (int u = 1 ; u <= n ; u++){
for (int v = u + 1 ; v <= n ; v++){
g[u].push_back({v , l});
g[v].push_back({u , l});
dijkstra();
if (d[t] <= k) ans++;
g[u].pop_back();
g[v].pop_back();
}
}
cout << ans << "\n";
}
#define name "A"
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen(name".INP" , "r")){
freopen(name".INP" , "r" , stdin);
freopen(name".OUT" , "w" , stdout);
}
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |