Advertisement
Korotkodul

ЗОШ 1-k bfs

Jan 12th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int,int>
  11. using namespace std;
  12. using ll = long long;
  13. using ld = long double;
  14. using db = double;
  15. void cv(vector <int> &v){
  16. for (auto x: v) cout<<x<<' ';
  17. cout<<"\n";
  18. }
  19.  
  20. void cvl(vector <ll> &v){
  21. for (auto x: v) cout<<x<<' ';
  22. cout<<"\n";
  23. }
  24.  
  25.  
  26. void cvv(vector <vector <int> > &v){
  27. for (auto x: v) cv(x);
  28. cout<<"\n";
  29. }
  30.  
  31. int n,m;
  32.  
  33. vector <int> d;
  34.  
  35.  
  36.  
  37. struct ed{
  38. int fr, to;
  39. ld w;
  40. };
  41.  
  42. vector <vector <ed>> G;
  43.  
  44. map
  45.  
  46. const int inf = 2e9;
  47.  
  48. void readG(){
  49. cin>>n>>m;
  50. G.resize(n);
  51. d.assign(n, inf);
  52. for (int i=0;i<m;++i){
  53. int a,b;
  54. ld w;
  55. cin>>a>>b>>w;
  56. a--; b--;
  57. w /= 1000.0;
  58. ed any = {a, b, w};
  59. G[a].push_back(any);
  60. }
  61. }
  62.  
  63. void shG(){
  64. cout<<"G\n";
  65. for (int i=0;i<n;++i){
  66. cout<<i+1<<"\n";
  67. for (auto x: G[i]){
  68. cout<<x.to+1<<' '<<fixed<<x.w<<"\n";
  69. }
  70. cout<<"\n";
  71. }
  72. }
  73.  
  74.  
  75.  
  76. void fndWaves(int s){
  77.  
  78. d[s] = 0;
  79.  
  80. }
  81.  
  82.  
  83. int main()
  84. {
  85. ios::sync_with_stdio(0);
  86. cin.tie(0);
  87. cout.tie(0);
  88. cout.precision(5);
  89. //cin>>n>>m;
  90. readG();
  91. //shG();
  92.  
  93. }
  94. /*
  95. 5 5
  96. 1 2 2000
  97. 1 3 1000
  98. 1 4 1200
  99. 2 3 1500
  100. 3 4 1500
  101.  
  102. 4
  103. 1 5
  104. 2 4
  105. 3 3
  106. 1 2
  107.  
  108. */
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement