Language: C++

[13t4047y@hcs]~/prokon/aoj/volume0% cat 59k.cc
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

template<typename T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<typename T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<typename T> inline bool semige(T x, T y){ return y - x < -EPS; }
template<typename T> inline bool semile(T x, T y){ return x - y < -EPS; }


struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;

int ccw(Point a, Point b, Point c)
{
  b -= a;
  c -= a;
  if(b.det(c) > 0.0)    return  1;         // counter clockwise
  if(b.det(c) < 0.0)    return -1;         // clockwise
  if(b.dot(c) < 0.0)    return  2;         // c--a--b on line
  if(norm(b) < norm(c)) return -2;         // a--b--c on line  return 0;
  return 0.0;
}

struct Line : public vector<Point>
{
public:
  Line(const Point& p, const Point& q){ this->pb(p);  this->pb(q); }

  Line rtn(){ return *this; }
  Point pt(){ return this->at(0); }

  Point projection(Point& p){return this->at(0)+((Point(p-this->at(0))).dot(this->at(0)-this->at(1))/norm(this->at(0)-this->at(1)))*(this->at(0)-this->at(1));}
  Point reflection(Point& p){return p+2.0*(this->projection(p)-p);}
  inline bool intersectionDeterminationOfLL(Line& l){return abs(Point(this->at(1)-this->at(0)).det(l[1]-l[0]))>EPS||abs(Point(this->at(1)-this->at(0)).det(l[0]-this->at(0)))<EPS;}
  inline bool intersectionDeterminationOfLS(Line& s){return (Point(this->at(1)-this->at(0)).det(s[0]-this->at(0)))*(Point(this->at(1)-this->at(0)).det(s[1]-this->at(0)))<EPS;}
  inline bool intersectionDeterminationOfLP(Point& p){return abs(Point(this->at(1)-p).det(this->at(0)-p))<EPS;}
  inline bool intersectionDeterminationOfSS(Line& s){return ccw(this->at(0),this->at(1),s[0])*ccw(this->at(0),this->at(1),s[1])<=0&&ccw(s[0],s[1],this->at(0))*ccw(s[0],s[1],this->at(1))<=0;}
  inline bool intersectionDeterminationOfSP(Point& p){return abs(this->at(0)-p)+abs(this->at(1)-p)-abs(this->at(1)-this->at(0))<EPS;}
  inline double distanceLP(Point& p){return abs(p-this->projection(p));}
  inline double distanceLL(Line& l){return this->intersectionDeterminationOfLL(l)?0.0:this->distanceLP(l[0]);}
  inline double distanceLS(Line& s){return this->intersectionDeterminationOfLS(s)?0.0:min(this->distanceLP(s[0]),this->distanceLP(s[1]));}
  inline double distanceSP(Point& p){Point r=this->projection(p);return this->intersectionDeterminationOfSP(r)?abs(r-p):min(abs(this->at(0)-p),abs(this->at(1)-p));}
  inline double distanceSS(Line& s){return this->intersectionDeterminationOfSS(s)?0.0:min(min(this->distanceSP(s[0]),this->distanceSP(s[1])),min(s.distanceSP(this->at(0)),s.distanceSP(this->at(1))));}
  Point intersection(Line& l){
    double A = Point(this->at(1)-this->at(0)).det(l[1]-l[0]);
    double B = Point(this->at(1)-this->at(0)).det(this->at(1)-l[0]);
    if(abs(A)<EPS && abs(B)<EPS) return l[0];
    if(abs(A)<EPS) assert(false);
    return l[0] + B/A * (l[1]-l[0]);
  }
};

#define currPoint(P, i) P[i]
#define nextPoint(P, i) P[(i+1)%P.size()]


/*
enum { OUT, ON, IN };
int contains(const Polygon& P, const Point& p)
{
  bool in = false;
  for (int i = 0; i < P.size(); ++i) {
    Point a = currPoint(P,i) - p, b = nextPoint(P,i) - p;
    if (semige(imag(a), imag(b))) swap(a, b);
    if (!semige(imag(a), 0.0) && semile(0.0, imag(b)))
      if (semile(a.det(b), 0.0)) in = !in;
    if (semieq(a.det(b), 0.0) && !semige(a.dot(b), 0.0)) return ON;
  }
  return in ? IN : OUT;
}
*/

enum { OUT, ON, IN };
int contains(const Polygon &P, const Point &p)
{
  const int n = P.size();
  Point g = (P[0] + P[n/3] + P[2*n/3]) / 3.0; // inner-Point
  int a = 0, b = n;
  while (a+1 < b) { // invariant: c is in fan g-P[a]-P[b]
    int c = (a + b) / 2;
    if (semige(Point(P[a]-g).det(P[c]-g), 0.0)) { // angle < 180 deg
      if (semige(Point(P[a]-g).det(p-g), 0.0) && semile(Point(P[c]-g).det(p-g), 0.0)) b = c;
      else                                                a = c;
    } else {
      if (semile(Point(P[a]-g).det(p-g), 0.0) && semige(Point(P[c]-g).det(p-g), 0.0)) a = c;
      else                                                b = c;
    }
  }
  b %= n;
  if (semile(Point(P[a] - p).det(P[b] - p), 0.0)) return 0;
  if (semige(Point(P[a] - p).det(P[b] - p), 0.0)) return 2;
  return 1;
}

double x[4];
double y[4];

int main()
{
  while(cin >> x[0] >> y[0] >> x[2] >> y[2]){
    x[1] = x[2];  y[1] = y[0];
    x[3] = x[0];  y[3] = y[2];
    Polygon a;
    vector<Line> A;
    rep(i, 4) a.pb(Point(x[i], y[i]));
    rep(i, 4) A.pb(Line(currPoint(a, i), nextPoint(a, i)));

    cin >> x[0] >> y[0] >> x[2] >> y[2];
    x[1] = x[2];  y[1] = y[0];
    x[3] = x[0];  y[3] = y[2];
    Polygon b;
    vector<Line> B;
    rep(i, 4) b.pb(Point(x[i], y[i]));
    rep(i, 4) B.pb(Line(currPoint(b, i), nextPoint(b, i)));

    bool ok = false;
    //vrep(v, A) vrep(w, B) ok |= v->intersectionDeterminationOfSS(*w);


    rep(i, 4) ok |= (contains(a, b[i]) != OUT);
    rep(i, 4) ok |= (contains(b, a[i]) != OUT);

    puts(ok ? "YES" : "NO");
  }


  return 0;
}

Compiler output:
a.cc:1:10: error: stray '@' in program
    1 | [13t4047y@hcs]~/prokon/aoj/volume0% cat 59k.cc
      |          ^
a.cc:1:1: error: expected unqualified-id before '[' token
    1 | [13t4047y@hcs]~/prokon/aoj/volume0% cat 59k.cc
      | ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
  443 |   typedef decltype(nullptr) nullptr_t;
      |                             ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
  670 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
  674 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
  678 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                              ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
 1440 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
 1441 |     struct rank<_Tp[_Size]>
      |                     ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
 1441 |     struct rank<_Tp[_Size]>
      |                           ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
 2086 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
 2087 |     struct remove_extent<_Tp[_Size]>
      |                              ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
 2087 |     struct remove_extent<_Tp[_Size]>
      |                                    ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
 2099 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                   ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                         ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
 2171 |   template<std::size_t _Len>
      |            ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
 2176 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |            ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |                              ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
 2195 |            __alignof__(typename __aligned_storage_msa<_Len>::__type)>
      |                                                       ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
 2195 |            __alignof__(typename __aligned_storage_msa<_Len>::__type)>
      |                                                           ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
 2202 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
 2203 |         struct __attribute__((__aligned__((_Align)))) { } __align;
      |                                            ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
                 from /usr/include/c++/14/bits/stl_algo.h:69,
                 from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
  131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                            ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
  132 |   __attribute__((__externally_visible__));
      |                                         ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
  133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
  133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                                              ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes