QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#710257 | #1982. Jogging | becaido | AC ✓ | 36ms | 11912kb | C++20 | 1.5kb | 2024-11-04 19:13:18 | 2024-11-04 19:13:18 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifdef WAIMAI
#define debug(HEHE...) cout<<"["<<#HEHE<<"] : ",dout(HEHE)
void dout(){cout<<'\n';}
template<typename T,typename...U>
void dout(T t,U...u){cout<<t<<(sizeof...(u)?", ":""),dout(u...);}
#else
#define debug(...) 7122
#endif
#define int long long
#define ll long long
#define Waimai ios::sync_with_stdio(false),cin.tie(0)
#define FOR(x,a,b) for(int x=a,I=b;x<=I;x++)
#define pb emplace_back
#define F first
#define S second
const int INF = 2e9;
const int SIZE = 1e5 + 5;
int n, m, ans;
int u, d;
int dis[SIZE];
vector<pair<int, int>> adj[SIZE];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
void solve() {
cin >> n >> m >> u >> d;
while (m--) {
int a, b, w;
cin >> a >> b >> w;
a++, b++;
adj[a].pb (b, w);
adj[b].pb (a, w);
}
fill (dis, dis + n + 1, INF);
dis[1] = 0, pq.emplace (0, 1);
while (pq.size()) {
auto [val, pos] = pq.top();
pq.pop();
if (val > dis[pos]) continue;
for (auto [np, w] : adj[pos]) if (val + w < dis[np]) {
dis[np] = val + w;
pq.emplace (dis[np], np);
}
}
FOR (i, 1, n) for (auto [j, w] : adj[i]) {
int val = min (dis[i], dis[j]);
if (2 * val < d) ans++;
}
cout << ans / 2 << '\n';
}
int32_t main() {
Waimai;
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3668kb
input:
1 0 1 1
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
2 1 5 10 0 1 3
output:
1
result:
ok single line: '1'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
2 1 10 12 0 1 13
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
3 2 1 2 0 1 3 1 2 3
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
3 2 6 6 0 1 3 1 2 3
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 1ms
memory: 5764kb
input:
3 2 6 12 0 1 3 1 2 3
output:
2
result:
ok single line: '2'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
3 3 9 9 0 1 3 1 2 3 0 2 3
output:
3
result:
ok single line: '3'
Test #8:
score: 0
Accepted
time: 1ms
memory: 5704kb
input:
3 3 1 7 0 1 3 1 2 3 0 2 3
output:
3
result:
ok single line: '3'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
3 3 1 6 0 1 3 1 2 3 0 2 3
output:
2
result:
ok single line: '2'
Test #10:
score: 0
Accepted
time: 0ms
memory: 5708kb
input:
3 3 1 2 0 1 3 1 2 3 0 2 3
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 1ms
memory: 5700kb
input:
4 5 100 120 0 1 1 0 2 1 0 3 1 1 2 1 2 3 1
output:
5
result:
ok single line: '5'
Test #12:
score: 0
Accepted
time: 1ms
memory: 5628kb
input:
4 5 4 4 0 1 2 0 2 2 0 3 1 1 2 1 2 3 1
output:
4
result:
ok single line: '4'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
3 2 6 12 2 1 4 1 0 2
output:
2
result:
ok single line: '2'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3724kb
input:
3 2 1 2 1 0 3 2 1 3
output:
1
result:
ok single line: '1'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
3 2 6 6 2 1 1 1 0 5
output:
1
result:
ok single line: '1'
Test #16:
score: 0
Accepted
time: 29ms
memory: 11820kb
input:
100000 100000 10290 42195 0 1 215 0 2 880 0 4 687 0 11 39 0 55 535 0 72 855 1 3 30 1 6 858 1 9 103 1 10 38 1 18 77 1 26 126 1 69 20 2 5 351 2 12 922 2 14 588 2 27 943 2 48 463 3 35 1000 3 38 704 3 50 986 3 67 639 4 8 357 4 20 305 5 7 96 6 16 262 6 82 971 9 21 581 9 90 149 10 13 353 10 15 984 10 23 5...
output:
1851
result:
ok single line: '1851'
Test #17:
score: 0
Accepted
time: 33ms
memory: 11812kb
input:
100000 100000 17806 42195 0 1 583 0 3 925 0 6 37 0 117 151 0 847 567 1 2 903 1 4 604 1 20 386 1 123 480 1 242 45 2 5 607 2 9 559 2 17 306 2 132 267 2 261 82 2 495 479 3 7 711 3 36 127 4 8 738 4 24 979 4 96 287 4 121 498 4 231 869 4 247 947 4 279 40 5 15 317 5 176 755 5 313 934 5 365 321 5 611 307 6 ...
output:
18825
result:
ok single line: '18825'
Test #18:
score: 0
Accepted
time: 36ms
memory: 11912kb
input:
95000 100000 27047 42195 0 1 293 0 2 995 1 3 590 1 7 25 2 4 841 2 11 894 3 6 384 3 13 793 4 5 216 4 9 720 5 8 644 5 10 482 5 14 117 8 16 57 10 12 474 12 18 430 13 17 247 14 15 424 14 21 170 14 23 460 15 19 351 15 22 734 19 20 923 21 27 460 23 24 959 23 25 309 23 29 516 24 31 452 24 33 891 25 26 644 ...
output:
95558
result:
ok single line: '95558'