Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cmath>
- #include <vector>
- #include <string>
- #include <set>
- #include <stack>
- #include <queue>
- #include <deque>
- using namespace std;
- #define TASK "pathbge1"
- struct edge {
- int a, b, tin, tout;
- };
- const int INF = 1e9 + 7;
- int n, m, v;
- edge e[10000];
- int d[10000];
- int main() {
- #ifdef _DEBUG
- freopen("debug.in", "r", stdin);
- freopen("debug.out", "w", stdout);
- #else
- //freopen(TASK".in", "r", stdin);
- //freopen(TASK".out", "w", stdout);
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif // _DEBUG
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int i, k, j, s, f, t1, t2;
- cin >> n >> s >> f >> m;
- for (i = 0; i < m; i++)
- cin >> e[i].a >> e[i].tout >> e[i].b >> e[i].tin;
- for (i = 0; i <= n; i++)
- d[i] = INF;
- d[s] = 0;
- for (i = 0; i < n; i++)
- for (j = 0; j < m; j++)
- if (/*d[e[j].a] < INF && */d[e[j].a] <= e[j].tout)
- d[e[j].b] = min(d[e[j].b], e[j].tin);
- cout << d[f] << " ";
- return 0;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement