Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. #include <vector>
  2. #include <tuple>
  3. #include <algorithm>
  4. #include <iostream>
  5.  
  6. #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
  7. #include <CGAL/Delaunay_triangulation_2.h>
  8. #include <CGAL/Triangulation_vertex_base_with_info_2.h>
  9. #include <CGAL/Triangulation_face_base_2.h>
  10. #include <boost/pending/disjoint_sets.hpp>
  11.  
  12. // Epic kernel is enough, no constructions needed, provided the squared distance
  13. // fits into a double (!)
  14. typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
  15. // we want to store an index with each vertex
  16. typedef std::size_t                                            Index;
  17. typedef CGAL::Triangulation_vertex_base_with_info_2<Index,K>   Vb;
  18. typedef CGAL::Triangulation_face_base_2<K>                     Fb;
  19. typedef CGAL::Triangulation_data_structure_2<Vb,Fb>            Tds;
  20. typedef CGAL::Delaunay_triangulation_2<K,Tds>                  Triangulation;
  21.  
  22. typedef K::Point_2 Point;
  23. typedef std::pair<Point, Index> IPoint;
  24. typedef std::vector<IPoint> IPoints;
  25. typedef std::tuple<Index,Index,K::FT> Edge;
  26. typedef std::vector<Edge> EdgeV;
  27.  
  28. void testcase() {
  29.     int n, m;
  30.     double p;
  31.     std::cin >> n >> m >> p;
  32.  
  33.     IPoints jammers(n);
  34.     for (int i = 0; i < n; ++i) {
  35.         Point j; std::cin >> j;
  36.         jammers[i] = {j, i};
  37.     }
  38.  
  39.     Triangulation t;
  40.     t.insert(jammers.begin(), jammers.end());
  41.  
  42.     EdgeV edges;
  43.     edges.reserve(3*n); // there can be no more in a planar graph
  44.     for (auto e = t.finite_edges_begin(); e != t.finite_edges_end(); ++e) {
  45.         Index i1 = e->first->vertex((e->second+1)%3)->info();
  46.         Index i2 = e->first->vertex((e->second+2)%3)->info();
  47.         // ensure smaller index comes first
  48.         if (i1 > i2) std::swap(i1, i2);
  49.         edges.emplace_back(i1, i2, t.segment(e).squared_length());
  50.     }
  51.     std::sort(edges.begin(), edges.end(),
  52.             [](const Edge& e1, const Edge& e2) -> bool {
  53.             return std::get<2>(e1) < std::get<2>(e2);
  54.                 });
  55.  
  56.  
  57.     boost::disjoint_sets_with_storage<> uf(n);
  58.     for (int i = 0; i < m; ++i) {
  59.         Point s, f;
  60.         std::cin >> s >> f;
  61.  
  62.         Point s_nearest = t.nearest_vertex(s)->point();
  63.         Point t_nearest = t.nearest_vertex(f)->point();
  64.  
  65.         double s_dist = CGAL::squared_distance(s, s_nearest);
  66.         double t_dist = CGAL::squared_distance(f, t_nearest);
  67.     }
  68.  
  69.     while (true) {
  70.        
  71.     }
  72.  
  73. }
  74.  
  75. int main() {
  76.     std::ios_base::sync_with_stdio(false);
  77.     int t; std::cin >> t;
  78.     while (t--) {
  79.         testcase();
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement