Submission #768946

#TimeUsernameProblemLanguageResultExecution timeMemory
768946aykhnTrampoline (info1cup20_trampoline)C++14
100 / 100
483 ms36428 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// author: aykhn

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

#define TC int t; cin >> t; while (t--) _();
#define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_setp tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define mpr make_pair
#define eb emplace_back
#define new int32_t
#define pb push_back
#define ts to_string
#define int ll
#define fi first
#define se second
#define ins insert
#define inf 0x3F3F3F3F
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount

int n, R, C;
pii a[200005];
int par[20][200005];



new main()
{
    OPT;
    cin >> R >> C >> n;

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].fi >> a[i].se;
    }

    int cnt = 0;

    sort(a + 1, a + n + 1);

    for (int i = 1; i <= n; i++)
    {
        int x = lower_bound(a + 1, a + n + 1, mpr(a[i].fi + 1, a[i].se)) - a;

        if (x == n + 1 || a[x].fi != a[i].fi + 1) continue;

        par[0][i] = x;
    }

    for (int i = 1; i < 20; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            par[i][j] = par[i - 1][par[i - 1][j]];
        }
    }

    int t;
    cin >> t;

    while (t--)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        if (x1 == x2 && y1 <= y2)
        {
            cout << "Yes" << endl;
            continue;
        }
        if (x1 > x2 || y1 > y2)
        {
            cout << "No" << endl;
            continue;
        }

        int node = lower_bound(a + 1, a + n + 1, mpr(x1, y1)) - a;

        if (node == n + 1 || a[node].fi != x1)
        {
            cout << "No" << endl;
            continue;
        }

        y1 = a[node].se;

        if (y1 > y2)
        {
            cout << "No" << endl;
            continue;
        }

        int dif = x2 - x1 - 1;

        for (int i = 19; i >= 0; i--)
        {
            if ((1 << i) <= dif)
            {
                node = par[i][node];
                dif -= (1 << i);
            }
        }
        if (!node || a[node].fi + 1 != x2 || a[node].se > y2) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
}

Compilation message (stderr)

trampoline.cpp: In function 'int32_t main()':
trampoline.cpp:47:9: warning: unused variable 'cnt' [-Wunused-variable]
   47 |     int cnt = 0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...