Language: C++

#include <bits/stdc++.h>
using namespace std;

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

using ll = long long;

ll R, C, n, a, b, c, d;
vector<T> xz, yz, xr, yc;
vector<T> v;

struct T {
  int x, y, id;
  T () {}
  T (ll x, ll y, ll id) : x(x), y(y), id(id) {}
  bool operator < (const T &t) const {
    if (x == t.x) return y < t.y;
    return x < t.x;
  }
};

int main() {
  init();
  cin >> R >> C >> n;
  rep(i,n) {
    cin >> a >> b >> c >> d;
    if (a == 0 and (c == 0 or c == R or d == 0 or d == C) or
        a == R and (c == 0 or c == R or d == 0 or d == C)) {
      if (a == 0) xz.push_back({a, b, i});
      else if (a == R) xr.push_back({a, b, i});
      else if (b == 0) yz.push_back({a, b, i});
      else yc.push_back({a, b, i});
      if (c == 0) xz.push_back({c, d, i});
      else if (c == R) xr.push_back({c, d, i});
      else if (d == 0) yz.push_back({c, d, i});
      else yc.push_back({c, d, i});
    }
  }

  int sxz, syz, sxr, syc;
  sxz = xz.size();
  syz = yz.size();
  sxr = xr.size();
  syc = yc.size();

  sort(all(xz));
  sort(all(yz));
  sort(all(xr));
  sort(all(yc));
  
  rep(i,sxz) v.push_back({xz[i].fi, xz[i].se, xz[i].id});
  rep(i,syc) v.push_back({yc[i].fi, yc[i].se, yc[i].id});
  for (int i = sxr - 1; i >= 0; i--) v.push_back({xr[i].fi, xr[i].se, xr[i].id});
  for (int i = syz - 1; i >= 0; i--) v.push_back({yz[i].fi, yz[i].se, yz[i].id});
  

  stack<T> st;
  map<T, bool> mp;

  rep(i,si) {
    //cout << v[i].x << " " << v[i].y << " " << v[i].id << endl;
    if (!mp[v[i]]) {
      st.push(v[i]);
      mp[v[i]] = true;
    }
    else {
      T t = st.top();
      st.pop();
      if (t.id != v[i].id) {
        cout << "NO" << endl;
        return 0;
      }
      else {
        mp[v[i]] = false;
      }
    }
  }

  cout << "YES" << endl;

  return 0;
}


Compiler output:
a.cc:20:8: error: 'T' was not declared in this scope
   20 | vector<T> xz, yz, xr, yc;
      |        ^
a.cc:20:9: error: template argument 1 is invalid
   20 | vector<T> xz, yz, xr, yc;
      |         ^
a.cc:20:9: error: template argument 2 is invalid
a.cc:21:8: error: 'T' was not declared in this scope
   21 | vector<T> v;
      |        ^
a.cc:21:9: error: template argument 1 is invalid
   21 | vector<T> v;
      |         ^
a.cc:21:9: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:40:22: error: request for member 'push_back' in 'xz', which is of non-class type 'int'
   40 |       if (a == 0) xz.push_back({a, b, i});
      |                      ^~~~~~~~~
a.cc:41:27: error: request for member 'push_back' in 'xr', which is of non-class type 'int'
   41 |       else if (a == R) xr.push_back({a, b, i});
      |                           ^~~~~~~~~
a.cc:42:27: error: request for member 'push_back' in 'yz', which is of non-class type 'int'
   42 |       else if (b == 0) yz.push_back({a, b, i});
      |                           ^~~~~~~~~
a.cc:43:15: error: request for member 'push_back' in 'yc', which is of non-class type 'int'
   43 |       else yc.push_back({a, b, i});
      |               ^~~~~~~~~
a.cc:44:22: error: request for member 'push_back' in 'xz', which is of non-class type 'int'
   44 |       if (c == 0) xz.push_back({c, d, i});
      |                      ^~~~~~~~~
a.cc:45:27: error: request for member 'push_back' in 'xr', which is of non-class type 'int'
   45 |       else if (c == R) xr.push_back({c, d, i});
      |                           ^~~~~~~~~
a.cc:46:27: error: request for member 'push_back' in 'yz', which is of non-class type 'int'
   46 |       else if (d == 0) yz.push_back({c, d, i});
      |                           ^~~~~~~~~
a.cc:47:15: error: request for member 'push_back' in 'yc', which is of non-class type 'int'
   47 |       else yc.push_back({c, d, i});
      |               ^~~~~~~~~
a.cc:52:12: error: request for member 'size' in 'xz', which is of non-class type 'int'
   52 |   sxz = xz.size();
      |            ^~~~
a.cc:53:12: error: request for member 'size' in 'yz', which is of non-class type 'int'
   53 |   syz = yz.size();
      |            ^~~~
a.cc:54:12: error: request for member 'size' in 'xr', which is of non-class type 'int'
   54 |   sxr = xr.size();
      |            ^~~~
a.cc:55:12: error: request for member 'size' in 'yc', which is of non-class type 'int'
   55 |   syc = yc.size();
      |            ^~~~
a.cc:10:20: error: request for member 'begin' in 'xz', which is of non-class type 'int'
   10 | #define all(v) (v).begin(), (v).end()
      |                    ^~~~~
a.cc:57:8: note: in expansion of macro 'all'
   57 |   sort(all(xz));
      |        ^~~
a.cc:10:33: error: request for member 'end' in 'xz', which is of non-class type 'int'
   10 | #define all(v) (v).begin(), (v).end()
      |                                 ^~~
a.cc:57:8: note: in expansion of macro 'all'
   57 |   sort(all(xz));
      |        ^~~
a.cc:10:20: error: request for member 'begin' in 'yz', which is of non-class type 'int'
   10 | #define all(v) (v).begin(), (v).end()
      |                    ^~~~~
a.cc:58:8: note: in expansion of macro 'all'
   58 |   sort(all(yz));
      |        ^~~
a.cc:10:33: error: request for member 'end' in 'yz', which is of non-class type 'int'
   10 | #define all(v) (v).begin(), (v).end()
      |                                 ^~~
a.cc:58:8: note: in expansion of macro 'all'
   58 |   sort(all(yz));
      |        ^~~
a.cc:10:20: error: request for member 'begin' in 'xr', which is of non-class type 'int'
   10 | #define all(v) (v).begin(), (v).end()
      |                    ^~~~~
a.cc:59:8: note: in expansion of macro 'all'
   59 |   sort(all(xr));
      |        ^~~
a.cc:10:33: error: request for member 'end' in 'xr', which is of non-class type 'int'
   10 | #define all(v) (v).begin(), (v).end()
      |                                 ^~~
a.cc:59:8: note: in expansion of macro 'all'
   59 |   sort(all(xr));
      |        ^~~
a.cc:10:20: error: request for member 'begin' in 'yc', which is of non-class type 'int'
   10 | #define all(v) (v).begin(), (v).end()
      |                    ^~~~~
a.cc:60:8: note: in expansion of macro 'all'
   60 |   sort(all(yc));
      |        ^~~
a.cc:10:33: error: request for member 'end' in 'yc', which is of non-class type 'int'
   10 | #define all(v) (v).begin(), (v).end()
      |                                 ^~~
a.cc:60:8: note: in expansion of macro 'all'
   60 |   sort(all(yc));
      |        ^~~
a.cc:62:16: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   62 |   rep(i,sxz) v.push_back({xz[i].fi, xz[i].se, xz[i].id});
      |                ^~~~~~~~~
a.cc:62:29: error: invalid types 'int[int]' for array subscript
   62 |   rep(i,sxz) v.push_back({xz[i].fi, xz[i].se, xz[i].id});
      |                             ^
a.cc:62:39: error: invalid types 'int[int]' for array subscript
   62 |   rep(i,sxz) v.push_back({xz[i].fi, xz[i].se, xz[i].id});
      |                                       ^
a.cc:62:49: error: invalid types 'int[int]' for array subscript
   62 |   rep(i,sxz) v.push_back({xz[i].fi, xz[i].se, xz[i].id});
      |                                                 ^
a.cc:63:16: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   63 |   rep(i,syc) v.push_back({yc[i].fi, yc[i].se, yc[i].id});
      |                ^~~~~~~~~
a.cc:63:29: error: invalid types 'int[int]' for array subscript
   63 |   rep(i,syc) v.push_back({yc[i].fi, yc[i].se, yc[i].id});
      |                             ^
a.cc:63:39: error: invalid types 'int[int]' for array subscript
   63 |   rep(i,syc) v.push_back({yc[i].fi, yc[i].se, yc[i].id});
      |                                       ^
a.cc:63:49: error: invalid types 'int[int]' for array subscript
   63 |   rep(i,syc) v.push_back({yc[i].fi, yc[i].se, yc[i].id});
      |                                                 ^
a.cc:64:40: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   64 |   for (int i = sxr - 1; i >= 0; i--) v.push_back({xr[i].fi, xr[i].se, xr[i].id});
      |                                        ^~~~~~~~~
a.cc:64:53: error: invalid types 'int[int]' for array subscript
   64 |   for (int i = sxr - 1; i >= 0; i--) v.push_back({xr[i].fi, xr[i].se, xr[i].id});
      |                                                     ^
a.cc:64:63: error: invalid types 'int[int]' for array subscript
   64 |   for (int i = sxr - 1; i >= 0; i--) v.push_back({xr[i].fi, xr[i].se, xr[i].id});
      |                                                               ^
a.cc:64:73: error: invalid types 'int[int]' for array subscript
   64 |   for (int i = sxr - 1; i >= 0; i--) v.push_back({xr[i].fi, xr[i].se, xr[i].id});
      |                                                                         ^
a.cc:65:40: error: request for member 'push_back' in 'v', which is of non-class type 'int'
   65 |   for (int i = syz - 1; i >= 0; i--) v.push_back({yz[i].fi, yz[i].se, yz[i].id});
      |                                        ^~~~~~~~~
a.cc:65:53: error: invalid types 'int[int]' for array subscript
   65 |   for (int i = syz - 1; i >= 0; i--) v.push_back({yz[i].fi, yz[i].se, yz[i].id});
      |                                                     ^
a.cc:65:63: error: invalid types 'int[int]' for array subscript
   65 |   for (int i = syz - 1; i >= 0; i--) v.push_back({yz[i].fi, yz[i].se, yz[i].id});
      |                                                               ^
a.cc:65:73: error: invalid types 'int[int]' for array subscript
   65 |   for (int i = syz - 1; i >= 0; i--) v.push_back({yz[i].fi, yz[i].se, yz[i].id});
      |                                                                         ^
a.cc:71:9: error: 'si' was not declared in this scope; did you mean 'i'?
   71 |   rep(i,si) {
      |         ^~
a.cc:6:43: note: in definition of macro 'repi'
    6 | #define repi(i,j,n) for(int i = (j); i < (n); ++i)
      |                                           ^
a.cc:71:3: note: in expansion of macro 'rep'
   71 |   rep(i,si) {
      |   ^~~
a.cc:73:14: error: invalid types 'int[int]' for array subscript
   73 |     if (!mp[v[i]]) {
      |              ^
a.cc:74:16: error: invalid types 'int[int]' for array subscript
   74 |       st.push(v[i]);
      |                ^
a.cc:75:11: error: invalid types 'int[int]' for array subscript
   75 |       mp[v[i]] = true;
      |           ^
a.cc:80:20: error: invalid types 'int[int]' for array subscript
   80 |       if (t.id != v[i].id) {
      |                    ^
a.cc:85:13: error: invalid types 'int[int]' for array subscript
   85 |         mp[v[i]] = false;
      |             ^