Language: C++

#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstdio>
#include<vector>
#include<cassert>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
#define debug(x) {cout<<(#x)<<" "<<x<<endl;}
using namespace std;
typedef long long LL;

inline int read() {
    int x=0,f=1; char ch=getchar();
    while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
    return x*f;
}

const int N = 100005;

int n,R,C;
int tot=0;
struct seg {
	int l,r;
} a[N];

inline bool cmp(const seg&a,const seg&b) {if (a.l==b.l) return a.r<b.r; return a.l<b.l;}

inline bool onSide(int x,int y) {
	return (x==0)||(y==0)||(x==R)||(y==C);
}

inline int G(int x,int y) {
	if (x==0) return y;
	if (y==C) return C+x;
	if (x==R) return C+R+C-y;
	return C+R+C+R-x;
}

inline seg getseg(int x1,int y1,int x2,int y2) {
	seg ret;
	int l=G(x1,y1),r=G(x2,y2);
	if (l>r)swap(l,r);
	ret.l=l,ret.r=r;
	return ret;
	
}

int main() {

	#ifndef ONLINE_JUDGE
	//	freopen("data.in","r",stdin);
	//	freopen("data.out","w",stdout);
	#endif

	R=read(),C=read(),n=read();
	rep(i,1,n) {
		int x1=read(),y1=read(),x2=read(),y2=read();
		if(onSide(x1,y1)&&onSide(x2,y2)) {
			a[++tot]=getseg(x1,y1,x2,y2);
		}
	}
	
	sort(a+1,a+tot+1,cmp);
	bool flag=1,rmost=-1;
	rep(i,2,tot) {
		if (a[i].l<=rmost&&a[i].r>=rmost) flag=0;
		rmost=max(rmost,a[i].r);
	}
	if (flag) puts("YES");
	else puts("NO");

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:26: error: no matching function for call to 'max(bool&, int&)'
   74 |                 rmost=max(rmost,a[i].r);
      |                       ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_tree.h:63,
                 from /usr/include/c++/14/set:62,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:74:26: note:   deduced conflicting types for parameter 'const _Tp' ('bool' and 'int')
   74 |                 rmost=max(rmost,a[i].r);
      |                       ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:11:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:74:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'bool'
   74 |                 rmost=max(rmost,a[i].r);
      |                       ~~~^~~~~~~~~~~~~~