답안 #387608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
387608 2021-04-09T03:49:34 Z 2qbingxuan Trampoline (info1cup20_trampoline) C++14
0 / 100
839 ms 35676 KB
#include <bits/stdc++.h>
#ifdef local
#define debug(a...) qqbx(#a, a)
template <typename ...T> void qqbx(const char *s, T ...a) {
    int cnt = sizeof...(T);
    ((std::cerr << "\033[1;32m(" << s << ") = (") , ... , (std::cerr << a << (--cnt ? ", " : ")\033[0m\n")));
}
#define pary(a...) danb(#a, a)
template <typename T> void danb(const char *s, T L, T R) {
    std::cerr << "\033[1;32m[ " << s << " ] = [ ";
    for (int f = 0; L != R; ++L) std::cerr << (f++ ? " " : "") << *L;
    std::cerr << " ]\033[0m\n";
}
#else
#define debug(...) ((void)0)
#define pary(...) ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define pb emplace_back

using namespace std;
const int inf = 1e9, MOD = 1000000007, maxn = 2525, LG = 20;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int R, C, N;
    cin >> R >> C >> N;
    vector<int> x(N), y(N);
    map<int, vector<pair<int,int>>> mp;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        mp[x[i]].emplace_back(y[i], i);
    }
    vector<vector<int>> to(N, vector<int>(LG));
    for (int i = 0; i < N; i++) {
        if (!mp.count(x[i]+1)) {
            to[i][0] = i;
        } else {
            auto &v = mp[x[i]+1];
            auto it = lower_bound(all(v), make_pair(y[i], 0));
            if (it == v.end())
                to[i][0] = i;
            else
                to[i][0] = it->second;
        }
    }
    for (int L = 1; L < LG; L++) {
        for (int i = 0; i < N; i++) {
            to[i][L] = to[to[i][L-1]][L-1];
        }
    }

    auto go = [&to, &y](int i, int dx) {
        for (int L = LG-1; L >= 0; L--) {
            if (dx >> L & 1)
                i = to[i][L];
        }
        return i;
    };
    auto answer = [](bool f) {
        cout << (f ? "Yes\n" : "No\n");
    };
    int q;
    cin >> q;
    while (q--) {
        int srcx, srcy, destx, desty;
        cin >> srcx >> srcy >> destx >> desty;
        if (srcx > destx) {
            answer(false);
        } else if (srcx == destx) {
            answer(destx <= desty);
        } else if (!mp.count(srcx)) {
            debug("CASE1");
            answer(false);
        } else {
            auto it = lower_bound(all(mp[srcx]), make_pair(srcy, 0));
            if (it == mp[srcx].end()) {
                debug("CASE2");
                answer(false);
            } else {
                debug("CASE3");
                int i = go(it->second, destx - srcx - 1);
                answer (x[i] == destx-1 && y[i] <= desty);
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1488 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 204 ms 28180 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 250 ms 27704 KB expected YES, found NO [4th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 972 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 839 ms 35676 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -