Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <cstdio>
  2. #include <utility>
  3. #include <vector>
  4. #include <map>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. vector<pair<pair<int, int>, pair<int, int>>> tunnels;
  9. map<pair<int, int>, int> paths;
  10.  
  11. int main() {
  12. int m, n, t;
  13. scanf("%d %d %d", &m, &n, &t);
  14. tunnels.reserve(t);
  15. while (t != 0) {
  16. int a1, a2, b1, b2;
  17. scanf("%d %d %d %d", &a1, &b1, &a2, &b2);
  18. tunnels.push_back(make_pair(make_pair(a1, b1), make_pair(a2, b2)));
  19. t--;
  20. }
  21. sort(tunnels.begin(), tunnels.end());
  22. paths[tunnels[0].first] = 1;
  23. pair<int, int> from, to;
  24. for (auto tunel : tunnels) {
  25. from = tunel.first;
  26. to = tunel.second;
  27. paths[to] = (paths[to] + paths[from]) % 999979;
  28. }
  29. printf("%d", paths[make_pair(m, n)]);
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement