Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <utility>
- #include <vector>
- #include <map>
- #include <algorithm>
- using namespace std;
- vector<pair<pair<int, int>, pair<int, int>>> tunnels;
- map<pair<int, int>, int> paths;
- int main() {
- int m, n, t;
- scanf("%d %d %d", &m, &n, &t);
- tunnels.reserve(t);
- while (t != 0) {
- int a1, a2, b1, b2;
- scanf("%d %d %d %d", &a1, &b1, &a2, &b2);
- tunnels.push_back(make_pair(make_pair(a1, b1), make_pair(a2, b2)));
- t--;
- }
- sort(tunnels.begin(), tunnels.end());
- paths[tunnels[0].first] = 1;
- pair<int, int> from, to;
- for (auto tunel : tunnels) {
- from = tunel.first;
- to = tunel.second;
- paths[to] = (paths[to] + paths[from]) % 999979;
- }
- printf("%d", paths[make_pair(m, n)]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement