Submission #354251

# Submission time Handle Problem Language Result Execution time Memory
354251 2021-01-21T15:40:28 Z valerikk Trampoline (info1cup20_trampoline) C++14
100 / 100
824 ms 62952 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 7;
const int L = 20;

int R, C, n;
pair<int, int> green[N];
int a[N], b[N];
int go[L][N];

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> R >> C >> n;
    for (int i = 0; i < n; ++i)
        cin >> green[i].second >> green[i].first;
    green[n] = {C + 1, R + 1};
    sort(green, green + n + 1);
    for (int i = 0; i <= n; ++i)
        a[i] = green[i].second, b[i] = green[i].first;
    for (int i = 0; i <= n; ++i)
        go[0][i] = n;
    map<int, int> last;
    for (int i = n - 1; i >= 0; --i) {
        if (last.find(a[i] + 1) != last.end())
            go[0][i] = last[a[i] + 1];
        last[a[i]] = i;
    }
    for (int p = 1; p < L; ++p) {
        for (int i = 0; i <= n; ++i)
            go[p][i] = go[p - 1][go[p - 1][i]];
    }
    map<int, vector<pair<int, int>>> for_x;
    for (int i = 0; i <= n; ++i)
        for_x[a[i]].emplace_back(b[i], i);
    int t;
    cin >> t;
    while (t--) {
        int xstart, ystart, xstop, ystop;
        cin >> xstart >> ystart >> xstop >> ystop;
        if (xstart > xstop || ystart > ystop) {
            cout << "No\n";
        } else if (xstart == xstop) {
               cout << "Yes\n";
           } else {
            auto it = lower_bound(for_x[xstart].begin(), for_x[xstart].end(), make_pair(ystart, 0));
            if (it == for_x[xstart].end() || it->first > ystop) {
                cout << "No\n";
            } else {
                int pos = it->second;
                for (int i = L - 1; i >= 0; --i) {
                    if (b[go[i][pos]] <= ystop)
                        pos = go[i][pos];
                }
                if (a[pos] + 1 >= xstop)
                    cout << "Yes\n";
                else
                    cout << "No\n";
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1388 KB 200 token(s): yes count is 21, no count is 179
2 Correct 5 ms 1644 KB 200 token(s): yes count is 70, no count is 130
3 Correct 4 ms 1260 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 157 ms 23172 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 162 ms 24172 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 101 ms 23148 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 151 ms 24320 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 435 ms 31608 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 447 ms 33624 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 464 ms 33588 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 508 ms 34156 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 521 ms 34224 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 607 ms 43244 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1004 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 1004 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 11 ms 1772 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 7 ms 1004 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 9 ms 1276 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 7 ms 1004 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 736 ms 42932 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 709 ms 36844 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 538 ms 34156 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 796 ms 62952 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 660 ms 43744 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 644 ms 33860 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 642 ms 33880 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 521 ms 33448 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 618 ms 43116 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 766 ms 43244 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 824 ms 52716 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 541 ms 33540 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 518 ms 33928 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 570 ms 34284 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 522 ms 33492 KB 200000 token(s): yes count is 129674, no count is 70326