Advertisement
Guest User

Points

a guest
Nov 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3.  
  4. const int maxN = 10000;
  5. const int mod = 666013;
  6.  
  7. int N;
  8. class Point
  9. {
  10. public:
  11. int x, y;
  12. Point(int _x = 0, int _y = 0):
  13. x(_x), y(_y) { }
  14. inline bool operator < (const Point& other) const {
  15. return (x == other.x) ? (y > other.y) : (x < other.x);
  16. }
  17. } p[maxN + 1];
  18.  
  19. int d[maxN + 1];
  20.  
  21. int main()
  22. {
  23. freopen("points.in", "r", stdin);
  24. freopen("points.out", "w", stdout);
  25. scanf("%d", &N);
  26.  
  27. for(int i = 1; i <= N; ++ i)
  28. scanf("%d %d", &p[i].x, &p[i].y);
  29.  
  30. std :: sort(p + 1, p + N + 1);
  31. d[1] = 1;
  32. for(int i = 2; i <= N; ++ i)
  33. {
  34. d[i] = 1;
  35. for(int j = i - 1; j > 0; -- j)
  36. if(p[j].y >= p[i].y)
  37. d[i] = (d[i] + d[j]) % mod;
  38. }
  39.  
  40. int Ans = 0;
  41. for(int i = 1; i <= N; ++ i)
  42. Ans = (Ans + d[i]) % mod;
  43. printf("%d\n", Ans);
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement