Language: C++

#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
int r,c,n,x1,y1,x2,y2;
inline bool isbound(int x,int y) {
    return !x||x==r||!y||y==c;
}
struct point {
    int x,y,id;
    point(){}
    point(int x,int y,int id):x(x),y(y),id(id){}
} p[maxn<<1];
inline bool cmp1(point p1,point p2) {
    return p1.x<p2.x;
}
inline bool cmp2(point p1,point p2) {
    return p1.y<p2.y;
}
inline bool cmp3(point p1,point p2) {
    return cmp1(p2,p1);
}
inline bool cmp4(point p1,point p2) {
    return cmp2(p2,p1);
}
vector<point> v;
stack<int> stk;
int main()
{
    scanf("%d%d%d",&r,&c,&n);
    for (int i=0;i<n;++i) {
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        if (isbound(x1,y1)&&isbound(x2,y2)) {
            v.push_back(point(x1,y1,i));
            v.push_back(point(x2,y2,i));
        }
    }
    sort(v.begin(),v.end(),cmp1);
    for (int i=0;i<(int)v.size();++i)
        if (v[i].y==0) {
            if (!stk.empty()&&stk.top()==v[i].id) {
                stk.pop();
                continue;
            }
            stk.push(v[i].id);
        }
    sort(v.begin(),v.end(),cmp2);
    for (int i=0;i<(int)v.size();++i)
        if (v[i].x==r&&v[i].y!=0&&v[i].y!=c) {
            if (!stk.empty()&&stk.top()==v[i].id) {
                stk.pop();
                continue;
            }
            stk.push(v[i].id);
        }
    sort(v.begin(),v.end(),cmp3);
    for (int i=0;i<(int)v.size();++i)
        if (v[i].y==c) {
            if (!stk.empty()&&stk.top()==v[i].id) {
                stk.pop();
                continue;
            }
            stk.push(v[i].id);
        }
    sort(v.begin(),v.end(),cmp4);
    for (int i=0;i<(int)v.size();++i)
        if (v[i].x==0&&v[i].y!=0&&v[i].y!=c) {
            if (!stk.empty()&&stk.top()==v[i].id) {
                stk.pop();
                continue;
            }
            stk.push(v[i].id);
        }
    puts(stk.empty()?"YES":"NO");
    return 0;
}


Compiler output:
a.cc:4:14: error: 'int y1' redeclared as different kind of entity
    4 | int r,c,n,x1,y1,x2,y2;
      |              ^~
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/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
                 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:32:24: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
   32 |         if (isbound(x1,y1)&&isbound(x2,y2)) {
      |                        ^~
      |                        |
      |                        double (*)(double) noexcept
a.cc:5:31: note:   initializing argument 2 of 'bool isbound(int, int)'
    5 | inline bool isbound(int x,int y) {
      |                           ~~~~^
a.cc:33:34: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
   33 |             v.push_back(point(x1,y1,i));
      |                                  ^~
      |                                  |
      |                                  double (*)(double) noexcept
a.cc:11:21: note:   initializing argument 2 of 'point::point(int, int, int)'
   11 |     point(int x,int y,int id):x(x),y(y),id(id){}
      |                 ~~~~^