fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct Point {
  5. long double x, y;
  6. };
  7.  
  8. int main() {
  9. ios::sync_with_stdio(false);
  10. cin.tie(nullptr);
  11.  
  12. long double W, H;
  13. cin >> W >> H; // dimenzije nisu potrebne u rešenju
  14.  
  15. int n;
  16. cin >> n;
  17.  
  18. vector<Point> p(n);
  19. for (int i = 0; i < n; ++i) cin >> p[i].x >> p[i].y;
  20.  
  21. const long double PI = acosl(-1.0L);
  22. const long double TWO_PI = 2.0L * PI;
  23. const long double EPS = 1e-12L;
  24.  
  25. vector<long double> ang;
  26. ang.reserve(max(0, n - 1));
  27.  
  28. for (int i = 0; i + 1 < n; ++i) {
  29. long double dx = p[i + 1].x - p[i].x;
  30. long double dy = p[i + 1].y - p[i].y;
  31. long double a = atan2l(dy, dx); // [-pi, pi]
  32. if (a < 0) a += TWO_PI; // [0, 2pi)
  33. ang.push_back(a);
  34. }
  35.  
  36. sort(ang.begin(), ang.end());
  37. int m = (int)ang.size();
  38.  
  39. long double bestGap = 0.0L;
  40. for (int i = 0; i + 1 < m; ++i) {
  41. bestGap = max(bestGap, ang[i + 1] - ang[i]);
  42. }
  43. bestGap = max(bestGap, ang[0] + TWO_PI - ang[m - 1]);
  44.  
  45. if (bestGap >= PI - EPS) cout << "DA\n";
  46. else cout << "NE\n";
  47.  
  48. return 0;
  49. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
DA