답안 #1086817

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086817 2024-09-11T14:23:04 Z LOLOLO Trampoline (info1cup20_trampoline) C++14
100 / 100
451 ms 58164 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define           s     second
#define           f     first
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (int)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 2e5 + 10;
map <int, set <pair <int, int>>> mp;
int nxt[N][20];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int r, c, n;
    cin >> r >> c >> n;

    vector <pair <int, int>> save;
    save.pb({-1, -1});

    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        save.pb({a, b});
    }

    sort(all(save));
    for (int i = 1; i < sz(save); i++) {
        mp[save[i].f].insert({save[i].s, i});
    }

    for (int i = sz(save) - 1; i >= 1; i--) {
        int x = save[i].f, y = save[i].s;
        auto T = mp[x + 1].lower_bound({y, 0});

        if (T == mp[x + 1].end())
            continue;

        nxt[i][0] = T -> s;
        for (int j = 1; j < 20; j++)
            nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
    }

    int t;
    cin >> t;

    while (t--) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1 > x2 || y1 > y2) {
            cout << "No\n";
            continue;
        }

        if (x2 == x1) {
            cout << "Yes\n";
            continue;
        }
        
        auto it = mp[x1].lower_bound({y1, 0});
        if (it == mp[x1].end()) {
            cout << "No\n";
            continue;
        }

        int len = x2 - x1 - 1, st = it -> s;
        for (int j = 0; j < 20; j++) {
            if (len & (1 << j)) {
                st = nxt[st][j];
            }
        }

        if (st == 0 || save[st].s > y2) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1624 KB 200 token(s): yes count is 21, no count is 179
2 Correct 4 ms 1884 KB 200 token(s): yes count is 70, no count is 130
3 Correct 3 ms 1372 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 29124 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 90 ms 29128 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 84 ms 28612 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 83 ms 29124 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 39288 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 210 ms 39368 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 221 ms 39364 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 216 ms 39620 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 232 ms 39624 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 237 ms 45632 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1372 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 5 ms 1372 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 6 ms 1884 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 5 ms 1372 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 5 ms 1372 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 4 ms 1300 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 344 ms 46952 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 287 ms 41156 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 218 ms 39352 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 451 ms 58164 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 282 ms 46020 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 245 ms 39528 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 244 ms 39368 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 238 ms 39524 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 350 ms 45664 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 315 ms 45664 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 373 ms 51920 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 216 ms 39300 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 222 ms 39364 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 255 ms 39624 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 197 ms 39368 KB 200000 token(s): yes count is 129674, no count is 70326