Language: C++

v#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define Cerr(x) cerr << (x) << endl
#define fi first
#define se second
#define P pair<ll, ll>
#define m_p make_pair

ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k, x2, y2;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};
pair<P, P> p[ohara];
ll p_cou;
ll dat1[ohara],dat2[ohara],dat3[ohara],dat4[ohara];

//-------------------------↓↓↓↓↓↓------------------------

bool border(ll nowy, ll nowx)
{
    if (nowy == 0 || nowx == 0)
        return true;
    else if (nowy == h || nowx == w)
        return true;
    else
        return false;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> h >> w >> n;
    rep(i, n)
    {
        cin >> y >> x >> y2 >> x2;
        dat1[i]=y;
        dat2[i]=x;
        dat3[i]=y2;
        dat4[i]=y2;
        if (!border(y, x) || !border(y2, x2))
            continue;
        if (y > y2)
        {
            swap(x, x2);
            swap(y, y2);
        }
        p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2));
    }
    sort(p, p + p_cou);
    ll limx = -1, limy = -1;
    ll limx2 = -1, limy2 = -1;
    ll splimx1 = -1, splimx2 = -1, splimx3 = -1, splimx4 = -1, splimy1 = -1, splimy2 = -1, splimy3 = -1, splimy4 = -1;
    ll dec1, dec2;
    rep(i, p_cou)
    {
        if (p[i].fi.fi == p[i].se.fi)
        {
            if (p[i].fi.fi == 0)
            {
                if (splimy1 == -1)
                {
                    splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1);
                    splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1);
                }
                else
                {
                    if ((splimy1 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy2) || (splimy1 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy2))
                    {
                        Cout("NO");
                        return 0;
                    }
                    else
                    {
                        splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1);
                        splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1);
                    }
                }
            }
            else
            {
                if (splimy3 == -1)
                {
                    splimy3 = min(p[i].fi.se * -1, p[i].se.se * -1);
                    splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1);
                }
                else
                {
                    if ((splimy3 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy4) || (splimy3 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy4))
                    {
                        Cout("NO");
                        return 0;
                    }
                    else
                    {
                        splimy3 = min(p[i].fi.se * -1, p[i].se.se * -1);
                        splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1);
                    }
                }
            }
        } /////////////////
        else if (p[i].fi.se == p[i].se.se)
        {
            if (p[i].fi.se == 0)
            {
                if (splimx1 == -1)
                {
                    splimx1 = min(p[i].fi.fi, p[i].se.fi);
                    splimx2 = max(p[i].fi.fi, p[i].se.fi);
                }
                else
                {
                    if ((splimx1 <= p[i].fi.fi && p[i].fi.fi <= splimx2) || (splimx1 <= p[i].se.fi && p[i].se.fi <= splimx2))
                    {
                        Cout("NO");
                        return 0;
                    }
                    else
                    {
                        splimx1 = min(p[i].fi.fi, p[i].se.fi);
                        splimx2 = max(p[i].fi.fi, p[i].se.fi);
                    }
                }
            }
            else
            {
                if (splimx3 == -1)
                {
                    splimx3 = min(p[i].fi.fi, p[i].se.fi);
                    splimx4 = max(p[i].fi.fi, p[i].se.fi);
                }
                else
                {
                    if ((splimx3 <= p[i].fi.fi && p[i].fi.fi <= splimx4) || (splimx3 <= p[i].se.fi && p[i].se.fi <= splimx4))
                    {
                        Cout("NO");
                        return 0;
                    }
                    else
                    {
                        splimx3 = min(p[i].fi.fi, p[i].se.fi);
                        splimx4 = max(p[i].fi.fi, p[i].se.fi);
                    }
                }
            }
        }
        else
        {
            ///////////////////////
            if (splimx1 != -1)
            {
                if ((splimx1 <= p[i].fi.fi && p[i].fi.fi <= splimx2 && p[i].fi.se * -1 == 0) || (splimx1 <= p[i].se.fi && p[i].se.fi <= splimx2 && p[i].se.se * -1 == 0))
                {
                    Cout("NO");
                    return 0;
                }
            }
            if (splimx3 != -1)
            {
                if ((splimx3 <= p[i].fi.fi && p[i].fi.fi <= splimx4 && p[i].fi.se * -1 == h) || (splimx3 <= p[i].se.fi && p[i].se.fi <= splimx4 && p[i].se.se * -1 == h))
                {
                    //cerr<<splimx3<<" "<<splimx4<<" "<<p[i].fi.fi<<" "<<p[i].se.fi<<"\n";
                    Cout("NO");
                    return 0;
                }
            }
            if (splimy1 != -1)
            {
                if ((splimy1 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy2 && p[i].fi.fi == 0) || (splimy1 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy2 && p[i].se.fi == 0))
                {
                    Cout("NO");
                    return 0;
                }
            }
            if (splimy3 != -1)
            {
                if ((splimy3 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy4 && p[i].fi.fi == w) || (splimy3 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy4 && p[i].se.fi == w))
                {
                    Cout("NO");
                    return 0;
                }
            }
            ///////////////////////
            dec1 = 0;
            dec2 = 0;
            if (limx == -1 && p[i].fi.fi <= p[i].se.fi)
            {
                limx = p[i].se.fi;
                limy = p[i].fi.se * -1;
                dec1 = 1;
            }
            else if (limx2 == -1 && p[i].fi.fi > p[i].se.fi)
            {
                limx2 = p[i].fi.fi;
                limy2 = p[i].se.se * -1;
                dec2 = 1;
            }
            if (limx != -1 && dec1 == 0)
            {
                if ((p[i].se.fi < limx && p[i].se.se * -1 > limy) || ((p[i].fi.fi < limx && p[i].fi.se * -1 > limy)))
                {
                    Cout("NO");
                    return 0;
                }
            }
            else if (limx2 != -1 && dec2 == 0)
            {
                if ((p[i].se.fi < limx2 && p[i].se.se * -1 < limy) || (p[i].fi.fi < limx2 && p[i].fi.se * -1 < limy))
                {
                    Cout("NO");
                    return 0;
                }
            }
            if (p[i].fi.fi <= p[i].se.fi)
            {
                limx = p[i].se.fi;
                limy = p[i].fi.se * -1;
            }
            else if (p[i].fi.fi > p[i].se.fi)
            {
                limx2 = p[i].fi.fi;
                limy2 = p[i].se.se * -1;
            }
        }
        //cerr << limx << " " << limy << " " << limx2 << " " << limy2 << "\n";
    }
    rep(i,n){
        if (splimx1 != -1)
            {
                if ((splimx1 <= dat2[i] && dat2[i] <= splimx2 && dat1[i] == 0) || (splimx1 <= dat4[i] && dat4[i] <= splimx2 && dat3[i] == 0))
                {
                    Cout("NO");
                    return 0;
                }
            }
            if (splimx3 != -1)
            {
                if ((splimx3 <= dat2[i] && dat2[i] <= splimx4 && dat1[i] == h) || (splimx3 <= dat4[i] && dat4[i] <= splimx4 && dat3[i] == h))
                {
                    //cerr<<splimx3<<" "<<splimx4<<" "<<p[i].fi.fi<<" "<<p[i].se.fi<<"\n";
                    Cout("NO");
                    return 0;
                }
            }
            if (splimy1 != -1)
            {
                if ((splimy1 <= dat1[i] && dat1[i] <= splimy2 && dat2[i] == 0) || (splimy1 <= dat3[i] && dat3[i] <= splimy2 && dat4[i] == 0))
                {
                    Cout("NO");
                    return 0;
                }
            }
            if (splimy3 != -1)
            {
                if ((splimy3 <= dat1[i] && dat1[i] <= splimy4 && dat2[i] == w) || (splimy3 <= dat3[i] && dat3[i] <= splimy4 && dat4[i] == w))
                {
                    Cout("NO");
                    return 0;
                }
            }
    }
    Cout("YES");
    return 0;
}


Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | v#include <bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'v' does not name a type
    1 | v#include <bits/stdc++.h>
      | ^
a.cc:5:7: error: 'll' does not name a type; did you mean 'ld'?
    5 | const ll LINF = 1e18;
      |       ^~
      |       ld
a.cc:20:1: error: 'll' does not name a type; did you mean 'ld'?
   20 | ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k, x2, y2;
      | ^~
      | ld
a.cc:26:1: error: 'string' does not name a type
   26 | string alph("abcdefghijklmnopqrstuvwxyz"), s;
      | ^~~~~~
a.cc:32:1: error: 'pair' does not name a type
   32 | pair<P, P> p[ohara];
      | ^~~~
a.cc:33:1: error: 'll' does not name a type; did you mean 'ld'?
   33 | ll p_cou;
      | ^~
      | ld
a.cc:34:1: error: 'll' does not name a type; did you mean 'ld'?
   34 | ll dat1[ohara],dat2[ohara],dat3[ohara],dat4[ohara];
      | ^~
      | ld
a.cc:38:13: error: 'll' was not declared in this scope; did you mean 'ld'?
   38 | bool border(ll nowy, ll nowx)
      |             ^~
      |             ld
a.cc:38:22: error: 'll' was not declared in this scope; did you mean 'ld'?
   38 | bool border(ll nowy, ll nowx)
      |                      ^~
      |                      ld
a.cc:38:29: error: expression list treated as compound expression in initializer [-fpermissive]
   38 | bool border(ll nowy, ll nowx)
      |                             ^
a.cc: In function 'int main()':
a.cc:50:5: error: 'cin' was not declared in this scope
   50 |     cin.tie(0);
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | v#include <bits/stdc++.h>
a.cc:51:5: error: 'ios' has not been declared
   51 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:53:12: error: 'h' was not declared in this scope
   53 |     cin >> h >> w >> n;
      |            ^
a.cc:53:17: error: 'w' was not declared in this scope
   53 |     cin >> h >> w >> n;
      |                 ^
a.cc:53:22: error: 'n' was not declared in this scope
   53 |     cin >> h >> w >> n;
      |                      ^
a.cc:56:16: error: 'y' was not declared in this scope
   56 |         cin >> y >> x >> y2 >> x2;
      |                ^
a.cc:56:21: error: 'x' was not declared in this scope
   56 |         cin >> y >> x >> y2 >> x2;
      |                     ^
a.cc:56:26: error: 'y2' was not declared in this scope
   56 |         cin >> y >> x >> y2 >> x2;
      |                          ^~
a.cc:56:32: error: 'x2' was not declared in this scope
   56 |         cin >> y >> x >> y2 >> x2;
      |                                ^~
a.cc:57:9: error: 'dat1' was not declared in this scope
   57 |         dat1[i]=y;
      |         ^~~~
a.cc:58:9: error: 'dat2' was not declared in this scope
   58 |         dat2[i]=x;
      |         ^~~~
a.cc:59:9: error: 'dat3' was not declared in this scope
   59 |         dat3[i]=y2;
      |         ^~~~
a.cc:60:9: error: 'dat4' was not declared in this scope
   60 |         dat4[i]=y2;
      |         ^~~~
a.cc:61:20: error: 'border' cannot be used as a function
   61 |         if (!border(y, x) || !border(y2, x2))
      |              ~~~~~~^~~~~~
a.cc:61:37: error: 'border' cannot be used as a function
   61 |         if (!border(y, x) || !border(y2, x2))
      |                               ~~~~~~^~~~~~~~
a.cc:65:13: error: 'swap' was not declared in this scope
   65 |             swap(x, x2);
      |             ^~~~
a.cc:68:9: error: 'p' was not declared in this scope
   68 |         p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2));
      |         ^
a.cc:68:11: error: 'p_cou' was not declared in this scope
   68 |         p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2));
      |           ^~~~~
a.cc:18:13: error: 'make_pair' was not declared in this scope
   18 | #define m_p make_pair
      |             ^~~~~~~~~
a.cc:68:26: note: in expansion of macro 'm_p'
   68 |         p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2));
      |                          ^~~
a.cc:1:1: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | v#include <bits/stdc++.h>
a.cc:18:13: error: 'make_pair' was not declared in this scope
   18 | #define m_p make_pair
      |             ^~~~~~~~~
a.cc:68:22: note: in expansion of macro 'm_p'
   68 |         p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2));
      |                      ^~~
a.cc:18:13: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
   18 | #define m_p make_pair
      |             ^~~~~~~~~
a.cc:68:22: note: in expansion of macro 'm_p'
   68 |         p[p_cou++] = m_p(m_p(x, -y), m_p(x2, -y2));
      |                      ^~~
a.cc:70:10: error: 'p' was not declared in this scope
   70 |     sort(p, p + p_cou);
      |          ^
a.cc:70:17: error: 'p_cou' was not declared in this scope
   70 |     sort(p, p + p_cou);
      |                 ^~~~~
a.cc:70:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   70 |     sort(p, p + p_cou);
      |     ^~~~
      |     short
a.cc:71:5: error: 'll' was not declared in this scope; did you mean 'ld'?
   71 |     ll limx = -1, limy = -1;
      |     ^~
      |     ld
a.cc:72:7: error: expected ';' before 'limx2'
   72 |     ll limx2 = -1, limy2 = -1;
      |       ^~~~~~
      |       ;
a.cc:73:7: error: expected ';' before 'splimx1'
   73 |     ll splimx1 = -1, splimx2 = -1, splimx3 = -1, splimx4 = -1, splimy1 = -1, splimy2 = -1, splimy3 = -1, splimy4 = -1;
      |       ^~~~~~~~
      |       ;
a.cc:74:7: error: expected ';' before 'dec1'
   74 |     ll dec1, dec2;
      |       ^~~~~
      |       ;
a.cc:81:21: error: 'splimy1' was not declared in this scope
   81 |                 if (splimy1 == -1)
      |                     ^~~~~~~
a.cc:83:31: error: 'min' was not declared in this scope; did you mean 'main'?
   83 |                     splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1);
      |                               ^~~
      |                               main
a.cc:84:21: error: 'splimy2' was not declared in this scope
   84 |                     splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1);
      |                     ^~~~~~~
a.cc:84:31: error: 'max' was not declared in this scope
   84 |                     splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1);
      |                               ^~~
a.cc:88:75: error: 'splimy2' was not declared in this scope
   88 |                     if ((splimy1 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy2) || (splimy1 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy2))
      |                                                                           ^~~~~~~
a.cc:13:17: error: 'cout' was not declared in this scope
   13 | #define Cout(x) cout << (x) << endl
      |                 ^~~~
a.cc:90:25: note: in expansion of macro 'Cout'
   90 |                         Cout("NO");
      |                         ^~~~
a.cc:13:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   13 | #define Cout(x) cout << (x) << endl
      |                 ^~~~
a.cc:90:25: note: in expansion of macro 'Cout'
   90 |                         Cout("NO");
      |                         ^~~~
a.cc:13:32: error: 'endl' was not declared in this scope
   13 | #define Cout(x) cout << (x) << endl
      |                                ^~~~
a.cc:90:25: note: in expansion of macro 'Cout'
   90 |                         Cout("NO");
      |                         ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | v#include <bits/stdc++.h>
a.cc:95:35: error: 'min' was not declared in this scope; did you mean 'main'?
   95 |                         splimy1 = min(p[i].fi.se * -1, p[i].se.se * -1);
      |                                   ^~~
      |                                   main
a.cc:96:35: error: 'max' was not declared in this scope
   96 |                         splimy2 = max(p[i].fi.se * -1, p[i].se.se * -1);
      |                                   ^~~
a.cc:102:21: error: 'splimy3' was not declared in this scope
  102 |                 if (splimy3 == -1)
      |                     ^~~~~~~
a.cc:104:31: error: 'min' was not declared in this scope; did you mean 'main'?
  104 |                     splimy3 = min(p[i].fi.se * -1, p[i].se.se * -1);
      |                               ^~~
      |                               main
a.cc:105:21: error: 'splimy4' was not declared in this scope
  105 |                     splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1);
      |                     ^~~~~~~
a.cc:105:31: error: 'max' was not declared in this scope
  105 |                     splimy4 = max(p[i].fi.se * -1, p[i].se.se * -1);
      |                               ^~~
a.cc:109:75: error: 'splimy4' was not declared in this scope
  109 |                     if ((splimy3 <= p[i].fi.se * -1 && p[i].fi.se * -1 <= splimy4) || (splimy3 <= p[i].se.se * -1 && p[i].se.se * -1 <= splimy4))
      |                                                                           ^~~~~~~
a.cc:13:17: error: 'cout' was not declared in this scope
   13 | #define Cout(x) cout << (x) << endl
      |                 ^~~~
a.cc:111:25: note: in expansion of macro 'Cout'
  111 |                         Cout("NO");
      |                         ^~~~
a.cc:13:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   13 | #define Cout(x) cout << (x) << endl
      |                 ^~~~
a.cc:111:25: note: in expansion of macro 'Cout'
  111 |                         Cout("NO");
      |                         ^~~~
a.cc:13:32: error: 'endl' was not declared in this scope
   13 | #define Cout(x) cout << (x) << endl
      |                                ^~~~
a.cc:111:25: note: in expansion of macro 'Cout'
  111 |                         Cout("NO");
      |                         ^~~~
a.cc:13:32: note: 'std::endl' is defined in he