-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1112.cpp
More file actions
48 lines (46 loc) · 1.24 KB
/
1112.cpp
File metadata and controls
48 lines (46 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* ____
* ____ ___ ____ ________ __/ __/
* / __ `__ \/ __ `/ ___/ / / / /_
* / / / / / / /_/ / / / /_/ / __/
* /_/ /_/ /_/\__,_/_/ \__,_/_/
*
* @link : https://the-redback.com
*/
#include <bits/stdc++.h>
using namespace std;
#define inf 10000000
#define mem(a, b) memset(a, b, sizeof(a))
#define NN 111
int pr[NN + 7];
int a[NN + 7][NN + 7];
int main() {
// freopen("C:\\Users\\Maruf Tuhin\\Desktop\\in.txt","r",stdin);
ios_base::sync_with_stdio(false);
int i, j, k, l, n, r, c, count, time;
int tc, t = 1;
int u, v, w;
cin >> tc;
while (tc--) {
cin >> n >> r >> time;
cin >> c;
for (i = 0; i <= n; i++) {
for (j = 0; j <= n; j++) a[i][j] = inf;
a[i][i] = 0;
}
while (c--) {
cin >> u >> v >> w;
a[u][v] = w;
}
for (k = 1; k <= n; k++)
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
if (t != 1) cout << "\n";
t++;
int sum = 0;
for (i = 1; i <= n; i++)
if (a[i][r] <= time) sum++;
cout << sum << "\n";
}
return 0;
}