fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <cassert>
  4. #include <cstdlib>
  5. #include <cstring>
  6. #include <cstdio>
  7. #include <cmath>
  8. #include <queue>
  9. #include <map>
  10. #include <set>
  11.  
  12. using namespace std;
  13.  
  14. #define type(x) __typeof((x).begin())
  15. #define foreach(i, x) for(type(x) i = (x).begin(); i != (x).end(); i++)
  16.  
  17. typedef long long ll;
  18. typedef pair < int, int > ii;
  19.  
  20. const int inf = 1e9 + 333;
  21. const ll linf = 1e18 + 333;
  22.  
  23. const int N = 5e4 + 5;
  24.  
  25. int n, m, t, k;
  26. int dist[N], q[N * 100];
  27. bool h[N];
  28. vector < ii > v[N];
  29.  
  30. int main () {
  31.  
  32. scanf("%d %d %d %d", &n, &m, &t, &k);
  33.  
  34. for(int i = 1; i <= n; i++)
  35. dist[i] = inf;
  36.  
  37. for(int i = 1; i <= m; i++) {
  38. int x, y, c;
  39. scanf("%d %d %d", &x, &y, &c);
  40. v[x].push_back({y, c});
  41. v[y].push_back({x, c});
  42. }
  43.  
  44. int ans = n;
  45.  
  46. for(int i = 1; i <= t; i++) {
  47. int x;
  48. scanf("%d", &x);
  49. if(dist[x]) {
  50. dist[x] = 0;
  51. int sz = 0;
  52. q[sz++] = x;
  53. for(int i = 0; i < sz; i++) {
  54. int x = q[i];
  55. ans -= !h[x];
  56. h[x] = 1;
  57. foreach(it, v[x]) {
  58. int u = it -> first;
  59. int e = it -> second;
  60. if(dist[x] + e < k and dist[x] + e < dist[u]) {
  61. dist[u] = dist[x] + e;
  62. q[sz++] = u;
  63. }
  64. }
  65. }
  66. }
  67. printf("%d\n", ans);
  68. }
  69.  
  70. return 0;
  71.  
  72. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:40: error: expected primary-expression before '{' token
prog.cpp:41: error: expected primary-expression before '{' token
stdout
Standard output is empty