# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1101261 | thangdz2k7 | Construction Project 2 (JOI24_ho_t2) | C++17 | 160 ms | 25908 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// author : thembululquaUwU
// 3.9.2024
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'
using namespace std;
using ll = long long;
using li = pair <ll, int>;
using ii = pair <int, int>;
using vi = vector <int>;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}
int n, m, s, t, l;
ll k, d[2][N];
vector <ii> adj[N];
priority_queue <li> qu;
const ll inf = 1e18;
void dij(ll *d){
for (int i = 1; i <= n; ++ i) d[i] ^= inf;
while (qu.size()){
auto [du, u] = qu.top(); qu.pop(); du = -du;
if (du != d[u]) continue;
for (auto [w, v] : adj[u]){
if (d[v] > d[u] + w){
d[v] = d[u] + w;
qu.push({-d[v], v});
}
}
}
}
void solve(){
cin >> n >> m;
cin >> s >> t >> l >> k;
for (int i = 1, a, b, c; i <= m; ++ i){
cin >> a >> b >> c;
adj[a].emplace_back(c, b);
adj[b].emplace_back(c, a);
}
d[0][s] = inf;
qu.push({0, s});
dij(d[0]);
d[1][t] = inf;
qu.push({0, t});
dij(d[1]);
if (d[0][t] <= k){
cout << ll(n - 1) * n / 2;
return;
}
for (int op : {0, 1}) sort(d[op] + 1, d[op] + n + 1);
int v = 0; ll ans = 0;
for (int u = n; u >= 1; -- u){
while (v < n && d[0][u] + d[1][v + 1] <= k - l) ++ v;
ans += v;
}
cout << ans;
}
int main(){
if (fopen("solve.inp", "r")){
freopen("solve.inp", "r", stdin);
freopen("solve.out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t = 1; // cin >> t;
while (t --) solve();
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... |