Language: C++

#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int r,c,n;
bool flag[2];
P p[2];
vector<int> xt;
vector<int> pt;

int main(void){
	scanf("%d%d%d",&r,&c,&n);
	bool res=true;
	for(int i=0;i<n;i++){
		scanf("%d%d",&p[0].first,&p[0].second);
		scanf("%d%d",&p[1].first,&p[1].second);
		if(abs(p[0].first-p[1].first)==r){
			if(p[0].first>p[1].first)swap(p[0],p[1]);
			if(abs(p[0].second-p[1].second)==c){
				if(flag[0] || flag[1])res=false;
				flag[0]=true;
				flag[1]=true;
				xt.push_back(P(p[0].second,p[1].second));
				if(p[0].second>p[1].second)swap(p[0],p[1]);
				yt.push_back(P(p[0].first,p[1].first));
			}else{
				if(flag[1])res=false;
				flag[0]=true;
				xt.push_back(P(p[0].second,p[1].second));
			}
		}else if(abs(p[0].second-p[1].second)==c){
			if(p[0].second>p[1].second)swap(p[0],p[1]);
			if(flag[0])res=false;
			flag[1]=true;
			yt.push_back(P(p[0].first,p[1].first));
		}
	}
	sort(xt.begin(),xt.end());
	sort(yt.begin(),yt.end());
	for(int i=0;i<(int)xt.size()-1;i++){
		if(xt[i].second>xt[i+1].second)res=false;
	}
	for(int i=0;i<(int)yt.size()-1;i++){
		if(yt[i].second>yt[i+1].second)res=false;
	}
	printf("%s\n",res?"YES":"NO");
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:45: error: no matching function for call to 'std::vector<int>::push_back(P)'
   36 |                                 xt.push_back(P(p[0].second,p[1].second));
      |                                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from 'P' {aka 'std::pair<int, int>'} to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from 'P' {aka 'std::pair<int, int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:38:33: error: 'yt' was not declared in this scope; did you mean 'xt'?
   38 |                                 yt.push_back(P(p[0].first,p[1].first));
      |                                 ^~
      |                                 xt
a.cc:42:45: error: no matching function for call to 'std::vector<int>::push_back(P)'
   42 |                                 xt.push_back(P(p[0].second,p[1].second));
      |                                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from 'P' {aka 'std::pair<int, int>'} to 'const std::vector<int>::value_type&' {aka 'const int&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from 'P' {aka 'std::pair<int, int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:48:25: error: 'yt' was not declared in this scope; did you mean 'xt'?
   48 |                         yt.push_back(P(p[0].first,p[1].first));
      |                         ^~
      |                         xt
a.cc:52:14: error: 'yt' was not declared in this scope; did you mean 'xt'?
   52 |         sort(yt.begin(),yt.end());
      |              ^~
      |              xt
a.cc:54:26: error: request for member 'second' in 'xt.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   54 |                 if(xt[i].second>xt[i+1].second)res=false;
      |                          ^~~~~~
a.cc:54:41: error: request for member 'second' in 'xt.std::vector<int>::operator[](((std::vector<int>::size_type)(i + 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   54 |                 if(xt[i].second>xt[i+1].second)res=false;
      |                                         ^~~~~~