fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct point
  5. {
  6. double x, y;
  7. };
  8.  
  9. bool corner(point a, point b, point c)
  10. {
  11. return ((double)(c.x - b.x) * (a.y - b.y) - (double)(a.x - b.x) * (c.y - b.y)) > 0;
  12. }
  13.  
  14. int main()
  15. {
  16. int n;
  17. cin >> n;
  18. vector <point> p(n);
  19. vector <pair<point, point> > ans;
  20. for (int i = 0; i < n; i++)
  21. {
  22. double a, b;
  23. cin >> a >> b;
  24. p[i] = {a, b};
  25. }
  26. p.push_back(p[0]);
  27. p.push_back(p[1]);
  28. for (int i = 0; i < p.size() - 2; i++)
  29. ans.push_back({p[i], p[i + 1]});
  30. //1 2 3 1 2
  31. for (int i = 1; i < p.size() - 1; i++)
  32. {
  33. if (!corner(p[i - 1], p[i], p[i + 1]))
  34. cout << p[i - 1].x << " " << p[i - 1].y << " " << p[i + 1].x << " " << p[i + 1].y << "\n";
  35. }
  36. }
Runtime error #stdin #stdout #stderr 0s 3472KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc