Advertisement
NHumme

F

Feb 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <vector>
  6. #include <string>
  7. #include <set>
  8. #include <stack>
  9. #include <queue>
  10. #include <deque>
  11. using namespace std;
  12.  
  13. #define TASK "pathbge1"
  14. struct edge {
  15.     int a, b, tin, tout;
  16. };
  17.  
  18. const int INF = 1e9 + 7;
  19. int n, m, v;
  20. edge e[10000];
  21. int d[10000];
  22.  
  23. int main() {
  24.  
  25. #ifdef _DEBUG
  26.     freopen("debug.in", "r", stdin);
  27.     freopen("debug.out", "w", stdout);
  28. #else
  29.     //freopen(TASK".in", "r", stdin);
  30.     //freopen(TASK".out", "w", stdout);
  31.     freopen("input.txt", "r", stdin);
  32.     freopen("output.txt", "w", stdout);
  33. #endif // _DEBUG
  34.  
  35.     ios_base::sync_with_stdio(0);
  36.     cin.tie(0);
  37.     cout.tie(0);
  38.  
  39.     int i, k, j, s, f, t1, t2;
  40.     cin >> n >> s >> f >> m;
  41.     for (i = 0; i < m; i++)
  42.         cin >> e[i].a >> e[i].tout >> e[i].b >> e[i].tin;
  43.     for (i = 0; i <= n; i++)
  44.         d[i] = INF;
  45.     d[s] = 0;
  46.     for (i = 0; i < n; i++)
  47.         for (j = 0; j < m; j++)
  48.             if (/*d[e[j].a] < INF && */d[e[j].a] <= e[j].tout)
  49.                 d[e[j].b] = min(d[e[j].b], e[j].tin);
  50.     cout << d[f] << " ";
  51.     return 0;
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement