Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <tuple>
- #include <algorithm>
- #include <iostream>
- #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
- #include <CGAL/Delaunay_triangulation_2.h>
- #include <CGAL/Triangulation_vertex_base_with_info_2.h>
- #include <CGAL/Triangulation_face_base_2.h>
- #include <boost/pending/disjoint_sets.hpp>
- // Epic kernel is enough, no constructions needed, provided the squared distance
- // fits into a double (!)
- typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
- // we want to store an index with each vertex
- typedef std::size_t Index;
- typedef CGAL::Triangulation_vertex_base_with_info_2<Index,K> Vb;
- typedef CGAL::Triangulation_face_base_2<K> Fb;
- typedef CGAL::Triangulation_data_structure_2<Vb,Fb> Tds;
- typedef CGAL::Delaunay_triangulation_2<K,Tds> Triangulation;
- typedef K::Point_2 Point;
- typedef std::pair<Point, Index> IPoint;
- typedef std::vector<IPoint> IPoints;
- typedef std::tuple<Index,Index,K::FT> Edge;
- typedef std::vector<Edge> EdgeV;
- void testcase() {
- int n, m;
- double p;
- std::cin >> n >> m >> p;
- IPoints jammers(n);
- for (int i = 0; i < n; ++i) {
- Point j; std::cin >> j;
- jammers[i] = {j, i};
- }
- Triangulation t;
- t.insert(jammers.begin(), jammers.end());
- EdgeV edges;
- edges.reserve(3*n); // there can be no more in a planar graph
- for (auto e = t.finite_edges_begin(); e != t.finite_edges_end(); ++e) {
- Index i1 = e->first->vertex((e->second+1)%3)->info();
- Index i2 = e->first->vertex((e->second+2)%3)->info();
- // ensure smaller index comes first
- if (i1 > i2) std::swap(i1, i2);
- edges.emplace_back(i1, i2, t.segment(e).squared_length());
- }
- std::sort(edges.begin(), edges.end(),
- [](const Edge& e1, const Edge& e2) -> bool {
- return std::get<2>(e1) < std::get<2>(e2);
- });
- boost::disjoint_sets_with_storage<> uf(n);
- for (int i = 0; i < m; ++i) {
- Point s, f;
- std::cin >> s >> f;
- Point s_nearest = t.nearest_vertex(s)->point();
- Point t_nearest = t.nearest_vertex(f)->point();
- double s_dist = CGAL::squared_distance(s, s_nearest);
- double t_dist = CGAL::squared_distance(f, t_nearest);
- }
- while (true) {
- }
- }
- int main() {
- std::ios_base::sync_with_stdio(false);
- int t; std::cin >> t;
- while (t--) {
- testcase();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement