답안 #768946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
768946 2023-06-29T00:20:48 Z aykhn Trampoline (info1cup20_trampoline) C++14
100 / 100
483 ms 36428 KB
#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

trampoline.cpp: In function 'int32_t main()':
trampoline.cpp:47:9: warning: unused variable 'cnt' [-Wunused-variable]
   47 |     int cnt = 0;
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2004 KB 200 token(s): yes count is 21, no count is 179
2 Correct 4 ms 2256 KB 200 token(s): yes count is 70, no count is 130
3 Correct 3 ms 1620 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 34760 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 70 ms 34860 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 78 ms 34900 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 72 ms 34808 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 345 ms 35540 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 362 ms 35956 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 356 ms 35864 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 383 ms 35920 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 367 ms 35920 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 364 ms 36200 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1432 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 9 ms 1620 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 9 ms 1492 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 9 ms 1636 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 9 ms 1628 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 9 ms 1620 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 441 ms 35576 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 483 ms 35660 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 363 ms 36148 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 466 ms 36192 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 399 ms 36428 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 369 ms 36200 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 399 ms 36084 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 367 ms 35848 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 431 ms 35900 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 457 ms 36176 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 480 ms 36052 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 406 ms 36064 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 356 ms 36184 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 413 ms 36192 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 355 ms 35940 KB 200000 token(s): yes count is 129674, no count is 70326