# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1262194 | tuanmwillwinvoi26 | Construction Project 2 (JOI24_ho_t2) | C++20 | 25 ms | 8264 KiB |
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
#define TASK "metro"
#define int long long
const int INF = 1e18 + 829;
const int MAXN = 3e3 + 5;
int n , m;
int s , t , l , k;
vector <pair<int , int>> adj[MAXN];
int dist_s[MAXN] , dist_t[MAXN];
int res;
priority_queue <pair<int , int> , vector<pair<int , int>> , greater<pair<int , int>>> pq;
bool ap[MAXN][MAXN];
void dijkstra(int node , int dist[]){
for(int i = 1 ; i <= n ; i ++){
dist[i] = INF;
}
dist[node] = 0;
pq.push({0 , node});
while(! pq.empty()){
int cost = pq.top().first;
int u = pq.top().second;
pq.pop();
if (cost != dist[u]) continue;
for(auto x : adj[u]){
int v = x.first;
int w = x.second;
if (dist[v] > dist[u] + w){
dist[v] = dist[u] + w;
pq.push({dist[v] , v});
}
}
}
}
signed main(){
if (fopen(TASK".inp" , "r")){
freopen(TASK".inp" , "r" , stdin);
freopen (TASK".ans" , "w" , stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> s >> t >> l >> k;
for(int i = 1 ; i <= m ; i ++){
int u , v , w;
cin >> u >> v >> w;
adj[u].push_back({v , w});
adj[v].push_back({u , w});
}
dijkstra(s , dist_s);
dijkstra(t , dist_t);
for(int i = 1 ; i <= n ; i ++){
for(int j = 1 ; j <= n ; j ++){
if (i == j) continue;
if (ap[i][j] == 1 || ap[j][i] == 1) continue;
if (dist_s[i] + l + dist_t[j] <= k){
res ++;
ap[i][j] = ap[j][i] = 1;
}
}
}
cout << res;
return 0;
}
/*
⠀⠀⠀⠀⠀⠀⢀⡤⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀
⠀⠀⠀⠀⠀⢀⡏⠀⠀⠈⠳⣄⠀⠀⠀⠀⠀⣀⠴⠋⠉⠉⡆
⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠈⠉⠉⠙⠓⠚⠁⠀⠀⠀⠀⣿
⠀⠀⠀⠀⢀⠞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣄
⠀⠀⠀⠀⡞⠀⠀⠀⠀⠀⠶⠀⠀⠀⠀⠀⠀⠦⠀⠀⠀⠀⠀⠸⡆
*/
컴파일 시 표준 에러 (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... |