Submission #989678

# Submission time Handle Problem Language Result Execution time Memory
989678 2024-05-28T14:39:05 Z coloboxx Trampoline (info1cup20_trampoline) C++17
0 / 100
385 ms 39404 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;

constexpr int N = 2e5 + 5;
constexpr int LOG = 19;
constexpr int INF = 1e9 + 9;

int x[N], y[N], jump[N][LOG], ans[N];
map<int, vector<pair<int, int>>> pos;

int get_nxt(int x, int y) {
    auto it = lower_bound(all(pos[x]), make_pair(y, -INF));
    return (it == pos[x].end() ? -1 : (*it).second);
}

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

    int h, w, n;
    cin >> h >> w >> n;

    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        pos[x[i]].push_back({y[i], i});
    }

    for (auto &&[x, v] : pos)
        sort(v.begin(), v.end());

    for (int i = 0; i < n; ++i)
        jump[i][0] = get_nxt(x[i] + 1, y[i]);
    
    for (int i = 0; i < n; ++i)
        for (int j = 1; j < LOG; ++j)
            jump[i][j] = jump[jump[i][j - 1]][j - 1];
    
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        if (x1 == x2) {
            cout << (y1 <= y2 ? "Yes\n" : "No\n");
            continue;
        }

        int v = get_nxt(x1, y1);

        if (v == -1 || x[v] > x2 || y[v] > y2) {
            cout << "No\n";
            continue;
        }

        for (int j = LOG - 1; j >= 0; --j)
            if (jump[v][j] != -1 && y[jump[v][j]] <= y2)
                v = jump[v][j];

        cout << (v == -1 || y[v] > y2 || x[v] < x2 - 1 ? "No\n" : "Yes\n");
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4700 KB expected NO, found YES [2nd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 22352 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 195 ms 31944 KB expected YES, found NO [8352nd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 4952 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 385 ms 39404 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -