Language: C++

// if both points not on the edge, it doesn't matter

// what if both points on the same edge

#include <stdio.h>
#include <algorithm>
#include <utility>
#include <map>

int t1,t2;

int r,c,n;
int xa[100005];
int ya[100005];     // int 'y1' redeclared as ...
int xb[100005];
int yb[100005];

std::pair<int,int> e[100005];
int e2;
std::map<int,int> take;     // for stuff on the same edge
std::map<int,int>::iterator it;

void swapp(int u)
{
    std::swap(xa[u],xb[u]);
    std::swap(ya[u],yb[u]);
}

bool work()
{
    // get edge stuff connected to (0,x)
    e2=0;
    take.clear();
    for (int i=0; i<n; i++) {
        if (xb[i]==0) swapp(i);
        if (xa[i]==0) {
            if (xb[i]==0) {
                // same edge
                if (xa[i]<xb[i]) swapp(i);
                take[xb[i]]=xa[i];
            }
            else if (yb[i]==0) {
                // edge 1
                e[e2++]={ya[i],xb[i]};
            }
            else if (xb[i]==r) {
                // edge 2
                e[e2++]={ya[i],yb[i]+150000000};
            }
            else if (yb[i]==c) {
                // edge 3
                e[e2++]={ya[i],450000000-xb[i]};
            }
        }
    }
    // check
    std::sort(e,e+e2);
    //printf("e2 %d\n",e2); for (int i=0; i<e2; i++) printf("edge %d %d\n",e[i]);
    for (int i=1; i<e2; i++) {
        if (e[i-1].second>e[i].second) {
            return 0;
        }
    }
    for (int i=0; i<e2; i++) {
        it=take.lower_bound(e[i].first);
        if (it!=take.end() && it->second<e[i].first) {
            return 0;
        }
    }
    it=take.begin();
    t1=take->first;
    t2=take->second;
    for (++it; it!=take.end(); ++it) {
        // check overlap
        // overlap is sequence t2 take->second t1 take->first
        if (t2<take->second && take->second<t1) return 0;
        t1=take->first;
        t2=take->second;
    }
    return 1;
}

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d%d%d",&r,&c,&n);
    for (int i=0; i<n; i++) {
        scanf("%d%d%d%d",xa+i,ya+i,xb+i,yb+i);
    }
    // do rotations
    for (int asdf=0; asdf<4; asdf++) {
        if (!work()) {
            printf("NO");
            return 0;
        }
        //return 0;
        // rotate 90 deg
        for (int i=0; i<n; i++) {
            t1=c-ya[i];
            t2=xa[i];
            xa[i]=t1;
            ya[i]=t2;
            t1=c-yb[i];
            t2=xb[i];
            xb[i]=t1;
            yb[i]=t2;
        }
        std::swap(r,c);
    }
    printf("YES");
}


Compiler output:
a.cc: In function 'bool work()':
a.cc:71:12: error: base operand of '->' has non-pointer type 'std::map<int, int>'
   71 |     t1=take->first;
      |            ^~
a.cc:72:12: error: base operand of '->' has non-pointer type 'std::map<int, int>'
   72 |     t2=take->second;
      |            ^~
a.cc:76:20: error: base operand of '->' has non-pointer type 'std::map<int, int>'
   76 |         if (t2<take->second && take->second<t1) return 0;
      |                    ^~
a.cc:76:36: error: base operand of '->' has non-pointer type 'std::map<int, int>'
   76 |         if (t2<take->second && take->second<t1) return 0;
      |                                    ^~
a.cc:77:16: error: base operand of '->' has non-pointer type 'std::map<int, int>'
   77 |         t1=take->first;
      |                ^~
a.cc:78:16: error: base operand of '->' has non-pointer type 'std::map<int, int>'
   78 |         t2=take->second;
      |                ^~