#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
ll n,m;
vector<vector<pair<ll,ll>>> cad;
vector<pair<ll,ll>> Dijkstra(ll ini)
{
vector<pair<ll,ll>> v(n+2, {1e16,1e16});
priority_queue<pair<ll,pair<ll,ll>>>q;
q.push({0,{ini,-1}});
while(!q.empty())
{
pair<ll,pair<ll,ll>> a=q.top();q.pop();
if(v[a.y.x].x==1e16)
{
v[a.y.x]={-a.x,a.y.y};
for(auto i:cad[a.y.x])
if(v[i.x].x==1e16)
q.push({a.x-i.y,{i.x,a.y.x}});
}
}
return v;
};
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;
cad.resize(n+1);
for(int i=0; i<m; i++)
{
ll a,b,c;
cin>>a>>b>>c;
cad[a].push_back({b,c});
cad[b].push_back({a,c});
}
vector<pair<ll,ll>> vs=Dijkstra(s);
vector<pair<ll,ll>> vt=Dijkstra(t);
if(vs[t].x<=k)
{
cout<<n*(n-1)/2;
return 0;
}
ll p=0;ll cont=0;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
//cout<<vs[i].x<<vt[j].x<<l<<"\n";
if(vs[i].x+vt[j].x+l<=k)
cont++;
}
}
cout<<cont;
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:48:8: warning: unused variable 'p' [-Wunused-variable]
48 | ll p=0;ll cont=0;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
860 KB |
Output is correct |
7 |
Execution timed out |
2086 ms |
26212 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
464 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
352 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
352 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
352 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
352 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
452 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
452 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
464 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
352 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
352 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
352 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
352 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
352 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
452 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
344 KB |
Output is correct |
29 |
Correct |
0 ms |
452 KB |
Output is correct |
30 |
Correct |
0 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
7 ms |
752 KB |
Output is correct |
34 |
Correct |
1 ms |
860 KB |
Output is correct |
35 |
Correct |
7 ms |
604 KB |
Output is correct |
36 |
Correct |
8 ms |
860 KB |
Output is correct |
37 |
Correct |
7 ms |
604 KB |
Output is correct |
38 |
Correct |
7 ms |
604 KB |
Output is correct |
39 |
Correct |
8 ms |
604 KB |
Output is correct |
40 |
Correct |
1 ms |
936 KB |
Output is correct |
41 |
Correct |
2 ms |
720 KB |
Output is correct |
42 |
Correct |
7 ms |
604 KB |
Output is correct |
43 |
Correct |
8 ms |
856 KB |
Output is correct |
44 |
Correct |
8 ms |
856 KB |
Output is correct |
45 |
Correct |
7 ms |
716 KB |
Output is correct |
46 |
Correct |
9 ms |
600 KB |
Output is correct |
47 |
Correct |
7 ms |
604 KB |
Output is correct |
48 |
Correct |
7 ms |
824 KB |
Output is correct |
49 |
Correct |
2 ms |
688 KB |
Output is correct |
50 |
Correct |
7 ms |
604 KB |
Output is correct |
51 |
Correct |
8 ms |
884 KB |
Output is correct |
52 |
Correct |
7 ms |
860 KB |
Output is correct |
53 |
Correct |
8 ms |
960 KB |
Output is correct |
54 |
Correct |
8 ms |
860 KB |
Output is correct |
55 |
Correct |
3 ms |
676 KB |
Output is correct |
56 |
Correct |
4 ms |
860 KB |
Output is correct |
57 |
Correct |
5 ms |
768 KB |
Output is correct |
58 |
Correct |
4 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
7 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
860 KB |
Output is correct |
7 |
Execution timed out |
2086 ms |
26212 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |