답안 #989683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
989683 2024-05-28T14:44:06 Z coloboxx Trampoline (info1cup20_trampoline) C++17
11 / 100
365 ms 27692 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() ? 0 : (*it).second);
}

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

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

    for (int i = 1; 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 = 1; i <= n; ++i)
        jump[i][0] = get_nxt(x[i] + 1, y[i]);
    
    for (int i = 1; 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 == 0 || x[v] > x2 || y[v] > y2) {
            cout << "No\n";
            continue;
        }

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

        cout << (v == 0 || y[v] > y2 || x[v] < x2 - 1 ? "No\n" : "Yes\n");
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 4700 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 114 ms 20584 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 165 ms 20160 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 181 ms 19936 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 196 ms 20480 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 235 ms 20812 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 239 ms 20836 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 351 ms 26708 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 4440 KB expected YES, found NO [8th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 365 ms 27692 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -