답안 #1107680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107680 2024-11-01T23:19:44 Z _callmelucian Trampoline (info1cup20_trampoline) C++14
100 / 100
276 ms 29644 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;

#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())

const int mn = 2e5 + 5;
vector<int> cmp, row[mn];
int nxt[mn][18], x[mn], y[mn];

bool found (int targ) {
    auto it = lower_bound(all(cmp), targ);
    return it != cmp.end() && *it == targ;
}

int getID (int targ)  {
    return lower_bound(all(cmp), targ) - cmp.begin() + 1;
}

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

    int r, c, n; cin >> r >> c >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
        cmp.push_back(x[i]);
    }
    sort(all(cmp)), filter(cmp);

    for (int i = 1; i <= n; i++)
        row[getID(x[i])].push_back(i);
    for (int i = 1; i <= n; i++)
        sort(all(row[i]), [&] (int a, int b) { return y[a] < y[b]; });

    for (int i = 1; i <= n; i++) {
        if (!found(x[i] + 1)) continue;
        int cur = getID(x[i] + 1);
        auto it = lower_bound(all(row[cur]), y[i],
                              [&] (int a, int b) { return y[a] < b; });
        if (it != row[cur].end()) nxt[i][0] = *it;
    }

    for (int s = 1; s < 18; s++)
        for (int i = 1; i <= n; i++)
            nxt[i][s] = nxt[nxt[i][s - 1]][s - 1];

    int q; cin >> q;
    while (q--) {
        int stx, sty, enx, eny; cin >> stx >> sty >> enx >> eny;
        if (stx > enx || enx - stx - 1 > n) {
            cout << "No\n";
            continue;
        }
        else if (stx == enx) {
            cout << (sty <= eny ? "Yes" : "No") << "\n";
            continue;
        }
        else {
            int curRow = getID(stx);
            auto it = lower_bound(all(row[curRow]), sty,
                                  [&] (int a, int b) { return y[a] < b; });
            if (it == row[curRow].end()) {
                cout << "No\n";
                continue;
            }
            int cur = *it;
            for (int step = enx - stx - 1, i = 0; step; step >>= 1, i++)
                if (step & 1) cur = nxt[cur][i];

            cout << (cur && y[cur] <= eny ? "Yes" : "No") << "\n";
        }
    }


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8272 KB 200 token(s): yes count is 21, no count is 179
2 Correct 6 ms 10588 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 8272 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 22844 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 101 ms 22980 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 97 ms 22724 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 103 ms 23000 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 187 ms 23500 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 197 ms 23492 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 185 ms 23236 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 202 ms 29496 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 199 ms 23492 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 225 ms 24448 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 8272 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 6 ms 8272 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 7 ms 8784 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 6 ms 8536 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 8528 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 8440 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 256 ms 24772 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 249 ms 25540 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 202 ms 23236 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 276 ms 28616 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 213 ms 24856 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 202 ms 23492 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 195 ms 23424 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 201 ms 23236 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 257 ms 24504 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 240 ms 24516 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 275 ms 26308 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 172 ms 23492 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 191 ms 29644 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 237 ms 23492 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 204 ms 23628 KB 200000 token(s): yes count is 129674, no count is 70326