fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. struct Point {
  7. long long x, y;
  8. bool operator<(const Point& other) const {
  9. if (x != other.x) return x < other.x;
  10. return y < other.y;
  11. }
  12. bool operator==(const Point& other) const {
  13. return x == other.x && y == other.y;
  14. }
  15. };
  16.  
  17.  
  18. int orientation(Point p, Point q, Point r) {
  19. long long val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
  20. if (val == 0) return 0;
  21. return (val > 0) ? 1 : 2;
  22. }
  23.  
  24.  
  25. bool onSegment(Point p, Point q, Point r) {
  26. return r.x <= max(p.x, q.x) && r.x >= min(p.x, q.x) &&
  27. r.y <= max(p.y, q.y) && r.y >= min(p.y, q.y);
  28. }
  29.  
  30. string solve() {
  31. Point a, b, c, d;
  32. if (!(cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y)) return "";
  33.  
  34. int o1 = orientation(a, b, c);
  35. int o2 = orientation(a, b, d);
  36. int o3 = orientation(c, d, a);
  37. int o4 = orientation(c, d, b);
  38.  
  39. if (((o1 > 0 && o2 > 0 && o1 != o2) || (o1 == 0 || o2 == 0)) &&
  40. ((o3 > 0 && o4 > 0 && o3 != o4) || (o3 == 0 || o4 == 0))) {
  41. if (o1 == 0 && o2 == 0 && o3 == 0 && o4 == 0) {
  42.  
  43. if (b < a) swap(a, b);
  44. if (d < c) swap(c, d);
  45.  
  46. Point max_start = max(a, c);
  47. Point min_end = min(b, d);
  48.  
  49. if (max_start == min_end) return "jedna";
  50. if (max_start < min_end) return "vise";
  51. return "nema";
  52. }
  53. return "jedna";
  54. }
  55.  
  56. return "nema";
  57. }
  58.  
  59. int main() {
  60. string result = solve();
  61. if (result != "") cout << result << endl;
  62. return 0;
  63. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty