Language: C++

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

namespace Geometry2D {
    const double EPS = 1e-10;
    double add(double a, double b) {
        if (abs(a + b) < Geometry2D::EPS * (abs(a) + abs(b))) return 0;
        return a + b;
    }
    int sgn(double a, double b = 0.0) {// sign function
        return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;
    }

    struct Point {//二次元座標
        double x, y;
        Point() {}
        Point(double _x, double _y) : x(_x), y(_y) {}
        const Geometry2D::Point operator+ (const Geometry2D::Point p) {
            return Point(Geometry2D::add(this->x, p.x), Geometry2D::add(this->y, p.y));
        }
        const Geometry2D::Point operator- (const Geometry2D::Point p) {
            return Point(Geometry2D::add(this->x, -p.x), Geometry2D::add(this->y, -p.y));
        }
        const Geometry2D::Point operator* (double d) {
            return Point(this->x * d, this->y * d);
        }
    };

    struct Line {
        Geometry2D::Point a, b, dis;
        Line() {}
        Line(const Geometry2D::Point &_a, const Geometry2D::Point &_b) : a(_a), b(_b), dis(b - a) {}
        double distSquare() { //距離の二乗
            return (this->a.x - this->b.x) * (this->a.x - this->b.x) + (this->a.y - this->b.y) * (this->a.y - this->b.y);
        }
        double distance() {
            return sqrt(this->distSquare());
        }
    };

    double naiseki(const Geometry2D::Point &p1, const Geometry2D::Point &p2) {
        return Geometry2D::add(p1.x * p2.x, p1.y * p2.y);
    }
    double gaiseki(const Geometry2D::Point &p1, const Geometry2D::Point &p2) {
        return Geometry2D::add(p1.x * p2.y, -p1.y * p2.x);
    }
    Point intersection(Geometry2D::Line &l1, Geometry2D::Line &l2) {//p1-p2とq1-q2の交点
        auto buf = (l1.b - l1.a);
        return l1.a + buf * (gaiseki(l2.b - l2.a, l2.a - l1.a) / gaiseki(l2.b - l2.a, l1.b - l1.a));
    }
    bool on_seg(Geometry2D::Point &p, Geometry2D::Line &l) {//線分l上にこの点pがあるか
        return Geometry2D::sgn(Geometry2D::gaiseki((l.a - p), (l.b - p))) == 0 && Geometry2D::naiseki(l.a - p, l.b - p) <= 0;
    }
    bool isIntersect(Geometry2D::Line &l1, Geometry2D::Line &l2) { // l1とl2が交差してるか
        Point intersect = intersection(l1, l2);
        return on_seg(intersect, l1) && on_seg(intersect, l2);
    }

    struct Circle {//円
        double r;//半径
        Point center;//中心座標
        Circle() {}
        Circle(double _x, double _y, double _r) : r(_r), center(_x, _y) {}
        Circle(const Point &_p, double _r) : r(_r), center(_p) {}
        bool inside(Point &p) {//円内部に居るか(円周含まない)
            return Geometry2D::sgn(Geometry2D::add(Geometry2D::Line(p, this->center).distSquare(), -(this->r * this->r))) == -1;
        }
        bool on_seg(Point &p) {//円周上に居るか
            return Geometry2D::sgn(Geometry2D::add(Geometry2D::Line(p, this->center).distSquare(), -(this->r * this->r))) == 0;
        }
        double square() {
            return this->r * this->r * acos(-1.0);
        }
    };
};
using namespace Geometry2D;
const int MAX = 1e5 + 10;
int R, C, N;
LL x1[MAX], y1[MAX], x2[MAX], y2[MAX];
PPL xy1[MAX], xy2[MAX];
VT<int> xseg, yseg;
BIT bit<LL>(MAX);
map<int, int> xcomp, ycomp;

int main(void) {
    scanf("%d%d%d", &R, &C, &N);
    REP(i, N) {
        scanf("%lld%lld%lld%lld", x1 + i, y1 + i, x2 + i, y2 + i);
        xy1[i] = MP(x1[i], y1[i]);
        xy2[i] = MP(x2[i], y2[i]);
        if ((x1[i] == 0 && x2[i] == R) ||(x2[i] == 0 && x1[i] == R)) {
            xseg.EB(i);
        }
        if ((y1[i] == 0 && y2[i] == C) ||(y2[i] == 0 && y1[i] == C)) {
            yseg.EB(i);
        }
    }
    set<int> xse, yse;
    REP(i, N) {
        xse.insert(x1[i]);
        xse.insert(x2[i]);
        yse.insert(y1[i]);
        yse.insert(y2[i]);
    }
    int cnt = 0;
    FORE(e, xse) {
        xcomp[e] = ++cnt;
    }
    cnt = 0;
    FORE(e, yse) {
        ycomp[e] = ++cnt;
    }
    if (xseg.size() >= 1 && yseg.size() >= 1) {
        cout << "NO" << endl;
        return 0;
    }
    if (xseg.size()) {
        VT<Line> v;
        xse.clear();
        FORE(i, xseg) {
            xse.EB(Line(Point(x1[i], y1[i]), Point(x2[i], y2[i])));
        }
        REP(i, N) {
            Line l = Line(Line(Point(x1[i], y1[i]), Point(x2[i], y2[i])));
            FORE(el, xse) {
                if (l.a.x == el.a.x && l.b.x == el.b.x && l.a.y == el.a.y && l.b.y == el.b.y) {
                    continue;
                }
                if (isIntersect(el, l)) {
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }
    } else {
        VT<Line> v;
        yse.clear();
        FORE(i, yseg) {
            yse.EB(Line(Point(x1[i], y1[i]), Point(x2[i], y2[i])));
        }
        REP(i, N) {
            Line l = Line(Line(Point(x1[i], y1[i]), Point(x2[i], y2[i])));
            FORE(el, xseg) {
                if (l.a.x == el.a.x && l.b.x == el.b.x && l.a.y == el.a.y && l.b.y == el.b.y) {
                    continue;
                }
                if (isIntersect(el, l)) {
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "YES" << endl;
}


Compiler output:
a.cc:138:19: error: 'LL y1 [100010]' redeclared as different kind of entity
  138 | LL x1[MAX], y1[MAX], x2[MAX], y2[MAX];
      |                   ^
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/bits/requires_hosted.h:31,
                 from /usr/include/c++/14/iostream:38,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc:139:1: error: 'PPL' does not name a type; did you mean 'PLL'?
  139 | PPL xy1[MAX], xy2[MAX];
      | ^~~
      | PLL
a.cc:141:1: error: 'BIT' does not name a type
  141 | BIT bit<LL>(MAX);
      | ^~~
a.cc: In function 'int main()':
a.cc:147:46: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  147 |         scanf("%lld%lld%lld%lld", x1 + i, y1 + i, x2 + i, y2 + i);
      |                                           ~~~^~~
a.cc:148:9: error: 'xy1' was not declared in this scope; did you mean 'y1'?
  148 |         xy1[i] = MP(x1[i], y1[i]);
      |         ^~~
      |         y1
a.cc:148:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  148 |         xy1[i] = MP(x1[i], y1[i]);
      |                                ^
a.cc:149:9: error: 'xy2' was not declared in this scope; did you mean 'y2'?
  149 |         xy2[i] = MP(x2[i], y2[i]);
      |         ^~~
      |         y2
a.cc:153:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  153 |         if ((y1[i] == 0 && y2[i] == C) ||(y2[i] == 0 && y1[i] == C)) {
      |                  ^
a.cc:153:61: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  153 |         if ((y1[i] == 0 && y2[i] == C) ||(y2[i] == 0 && y1[i] == C)) {
      |                                                             ^
a.cc:153:63: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  153 |         if ((y1[i] == 0 && y2[i] == C) ||(y2[i] == 0 && y1[i] == C)) {
      |                                                         ~~~~~~^~~~
a.cc:161:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  161 |         yse.insert(y1[i]);
      |                        ^
a.cc:161:19: error: no matching function for call to 'std::set<int>::insert(double (&)(double) noexcept)'
  161 |         yse.insert(y1[i]);
      |         ~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/set:63,
                 from a.cc:19:
/usr/include/c++/14/bits/stl_set.h:511:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<int>, int>::rebind<int>; typename _Alloc::value_type = int; value_type = int]' (near match)
  511 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:511:7: note:   conversion of argument 1 would be ill-formed:
a.cc:161:24: error: invalid conversion from 'double (*)(double) noexcept' to 'std::set<int>::value_type' {aka 'int'} [-fpermissive]
  161 |         yse.insert(y1[i]);
      |                    ~~~~^
      |                        |
      |                        double (*)(double) noexcept
/usr/include/c++/14/bits/stl_set.h:520:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<int>, int>::rebind<int>; typename _Alloc::value_type = int; value_type = int]' (near match)
  520 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:520:7: note:   conversion of argument 1 would be ill-formed:
a.cc:161:24: error: invalid conversion from 'double (*)(double) noexcept' to 'std::set<int>::value_type' {aka 'int'} [-fpermissive]
  161 |         yse.insert(y1[i]);
      |                    ~~~~^
      |                        |
      |                        double (*)(double) noexcept
/usr/include/c++/14/bits/stl_set.h:568:9: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  568 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:548:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, const value_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; value_type = int]'
  548 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:548:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:553:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, value_type&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; value_type = int]'
  553 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:553:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:580:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  580 |       insert(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:580:43: note:   no known conversion for argument 1 from 'double(double) noexcept' to 'std::initializer_list<int>'
  580 |       insert(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:600:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::insert_return_type std::set<_Key, _Compare, _Alloc>::insert(node_type&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; insert_return_type = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::insert_return_type; node_type = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::node_type]'
  600 |       insert(node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:600:26: note:   no known conversion for argument 1 from 'double(double) noexcept' to 'std::set<int>::node_type&&' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::node_type&&'}
  600 |       insert(node_type&& __nh)
      |              ~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_set.h:605:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, node_type&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; node_type = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::node_type]'
  605 |       insert(const_iterator __hint, node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:605:7: note:   candidate expects 2 arguments, 1 provided
a.cc:55:12: error: 'class std::set<int>' has no member named 'emplace_back'; did you mean 'emplace_hint'?
   55 | #define EB emplace_back
      |            ^~~~~~~~~~~~
a.cc:180:17: note: in expansion of macro 'EB'
  180 |             xse.EB(Line(Point(x1[i], y1[i]), Point(x2[i], y2[i])));
      |                 ^~
a.cc:180:42: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  180 |             xse.EB(Line(Point(x1[i], y1[i]), Point(x2[i], y2[i])));
      |                                          ^
a.cc:180:43: error: no matching function for call to 'Geometry2D::Point::Point(LL&, double (&)(double) noexcept)'
  180 |             xse.EB(Line(Point(x1[i], y1[i]), Point(x2[i], y2[i])));
      |                                           ^
a.cc:76:9: note: candidate: 'Geometry2D::Point::Point(double, double)'
   76 |         Point(double _x, double _y) : x(_x), y(_y) {}
      |         ^~~~~
a.cc:76:33: n