Submission #11647366


Source Code Expand

// Date: 2020-04-07

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, m, k;
pii a[N];

bool ok(int x, int y) {
    return x == 0 || x == n || y == 0 || y == m;
}

int get(int x, int y) {
    if(!x) return y;
    if(y == m) return m + x;
    if(x == n) return m + n + m - y;
    return m + n + m + n - x;
}

int stk[N], top;
int main() {
    FIO;
    cin >> n >> m >> k;
    int tot = 0;
    rep(i, 1, k) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(ok(x1, y1) && ok(x2, y2)) {
            a[++tot] = mk(get(x1, y1), i);
            a[++tot] = mk(get(x2, y2), i);
        }
    }
    sort(a+1, a+1+tot);
    rep(i, 1, tot) {
        stk[++top] = a[i].se;
        if(top > 1 && stk[top] == stk[top-1]) top -= 2;
    }
    if(top == 0) cout << "YES";
    else cout << "NO";

    return 0;
}

Submission Info

Submission Time
Task E - Connected?
User Gladinum
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1825 Byte
Status AC
Exec Time 52 ms
Memory 2176 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 4
AC × 38
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 43.txt, 44.txt, 45.txt, 46.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt AC 46 ms 1408 KB
02.txt AC 45 ms 1280 KB
03.txt AC 46 ms 1280 KB
04.txt AC 39 ms 640 KB
05.txt AC 45 ms 1280 KB
06.txt AC 51 ms 1920 KB
07.txt AC 39 ms 512 KB
08.txt AC 47 ms 1536 KB
09.txt AC 42 ms 896 KB
10.txt AC 50 ms 1920 KB
11.txt AC 48 ms 1664 KB
12.txt AC 37 ms 256 KB
13.txt AC 39 ms 512 KB
14.txt AC 42 ms 1024 KB
15.txt AC 44 ms 1152 KB
16.txt AC 39 ms 384 KB
17.txt AC 38 ms 256 KB
18.txt AC 37 ms 256 KB
19.txt AC 40 ms 768 KB
20.txt AC 51 ms 2048 KB
21.txt AC 43 ms 896 KB
22.txt AC 44 ms 1024 KB
23.txt AC 52 ms 2176 KB
24.txt AC 52 ms 2176 KB
25.txt AC 52 ms 2048 KB
26.txt AC 52 ms 2176 KB
27.txt AC 52 ms 2048 KB
28.txt AC 50 ms 2176 KB
29.txt AC 52 ms 2048 KB
30.txt AC 52 ms 2048 KB
43.txt AC 1 ms 256 KB
44.txt AC 1 ms 256 KB
45.txt AC 1 ms 256 KB
46.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB
s4.txt AC 1 ms 256 KB