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;

/**
* Binary_Indexed_Tree(BIT)
* Fenwick Tree
* 1-indexed!!!
*/
template<typename T = int>
class BIT {
private:
  std::vector<T> bit;
  const int N;
public:
  BIT() : N(-1) {}
  BIT(int n) : N(n), bit(n + 1, 0) {}
  //bit[point]にnum追加
  void add(int point, T num) {
      assert(N != -1 && 0 <= point && point <= N);
      while (point <= N) {
          bit[point] += num;
          point += point & -point;
      }
  }
  //pointまでの値の和を返す
  T sum(int point) {
      assert(N != -1 && 0 <= point && point <= N);
      T res = 0;
      while (point > 0) {
          res += bit[point];
          point -= point & -point;
      }
      return res;
  }
  //left から right の区間和
  T sum(int left, int right) {
      return this->sum(right) - this->sum(left - 1);
  }
};

const int MAX = 1e5 + 10;
int R, C, N;
LL x1[MAX], y1[MAX], x2[MAX], y2[MAX];
PLL xy1[MAX], xy2[MAX];
VT<int> xseg, yseg;
map<int, int> xcomp, ycomp;
BIT<int> bit(MAX);

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.empty()&& !yseg.empty()) {
        cout << "NO" << endl;
        return 0;
    }
    if (!xseg.empty()) {
        FORE(e, xseg) {
            bit.add(ycomp[y1[e]], 1);
            bit.add(ycomp[y2[e]] + 1, -1);
        }
        FORE(e, xseg) {
            if (bit.sum(ycomp[y1[e]]) != bit.sum(ycomp[y2[e]])) {
                cout << "NO" << endl;
                return 0;
            }
        }
    } else if (!yseg.empty()) {
        FORE(e, yseg) {
            bit.add(xcomp[x1[e]], 1);
            bit.add(xcomp[x2[e]] + 1, -1);
        }
        FORE(e, yseg) {
            if (bit.sum(xcomp[x1[e]]) != bit.sum(xcomp[x2[e]])) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}


Compiler output:
a.cc:102:19: error: 'LL y1 [100010]' redeclared as different kind of entity
  102 | 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: In function 'int main()':
a.cc:111:46: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  111 |         scanf("%lld%lld%lld%lld", x1 + i, y1 + i, x2 + i, y2 + i);
      |                                           ~~~^~~
a.cc:112:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  112 |         xy1[i] = MP(x1[i], y1[i]);
      |                                ^
a.cc:112:33: error: no match for 'operator=' (operand types are 'PLL' {aka 'std::pair<long long int, long long int>'} and 'std::pair<long long int, double (*)(double) noexcept>')
  112 |         xy1[i] = MP(x1[i], y1[i]);
      |                                 ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stl_pair.h:946:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = long long int; _T2 = long long int]'
  946 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:946:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h: In substitution of 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<long long int&, const _U1&>, std::is_assignable<long long int&, const _U2&> >::value, std::pair<long long int, long long int>&>::type std::pair<long long int, long long int>::operator=(const std::pair<_T1, _T2>&) [with _U1 = long long int; _U2 = double (*)(double) noexcept]':
a.cc:112:33:   required from here
  112 |         xy1[i] = MP(x1[i], y1[i]);
      |                                 ^
/usr/include/c++/14/bits/stl_pair.h:946:9: error: no type named 'type' in 'struct std::enable_if<false, std::pair<long long int, long long int>&>'
  946 |         operator=(const pair<_U1, _U2>& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:957:9: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = long long int; _T2 = long long int]'
  957 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:957:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_pair.h: In substitution of 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<long long int&, _U1&&>, std::is_assignable<long long int&, _U2&&> >::value, std::pair<long long int, long long int>&>::type std::pair<long long int, long long int>::operator=(std::pair<_T1, _T2>&&) [with _U1 = long long int; _U2 = double (*)(double) noexcept]':
a.cc:112:33:   required from here
  112 |         xy1[i] = MP(x1[i], y1[i]);
      |                                 ^
/usr/include/c++/14/bits/stl_pair.h:957:9: error: no type named 'type' in 'struct std::enable_if<false, std::pair<long long int, long long int>&>'
  957 |         operator=(pair<_U1, _U2>&& __p)
      |         ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:921:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = long long int; _T2 = long long int; std::__conditional_t<((bool)std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value), const std::pair<_T1, _T2>&, const std::__nonesuch&> = const std::pair<long long int, long long int>&]'
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:923:65: note:   no known conversion for argument 1 from 'std::pair<long long int, double (*)(double) noexcept>' to 'std::__conditional_t<true, const std::pair<long long int, long long int>&, const std::__nonesuch&>' {aka 'const std::pair<long long int, long long int>&'}
  921 |       operator=(__conditional_t<__and_<is_copy_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  922 |                                        is_copy_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  923 |                                 const pair&, const __nonesuch&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_pair.h:931:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = long long int; _T2 = long long int; std::__conditional_t<((bool)std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value), std::pair<_T1, _T2>&&, std::__nonesuch&&> = std::pair<long long int, long long int>&&]'
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:933:55: note:   no known conversion for argument 1 from 'std::pair<long long int, double (*)(double) noexcept>' to 'std::__conditional_t<true, std::pair<long long int, long long int>&&, std::__nonesuch&&>' {aka 'std::pair<long long int, long long int>&&'}
  931 |       operator=(__conditional_t<__and_<is_move_assignable<_T1>,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  932 |                                        is_move_assignable<_T2>>::value,
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  933 |                                 pair&&, __nonesuch&&> __p)
      |                                 ~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:117:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  117 |         if ((y1[i] == 0 && y2[i] == C) ||(y2[i] == 0 && y1[i] == C)) {
      |                  ^
a.cc:117:61: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  117 |         if ((y1[i] == 0 && y2[i] == C) ||(y2[i] == 0 && y1[i] == C)) {
      |                                                             ^
a.cc:117:63: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  117 |         if ((y1[i] == 0 && y2[i] == C) ||(y2[i] == 0 && y1[i] == C)) {
      |                                                         ~~~~~~^~~~
a.cc:125:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  125 |         yse.insert(y1[i]);
      |                        ^
a.cc:125:19: error: no matching function for call to 'std::set<int>::insert(double (&)(double) noexcept)'
  125 |         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:125:24: error: invalid conversion from 'double (*)(double) noexcept' to 'std::set<int>::value_type' {aka 'int'} [-fpermissive]
  125 |         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