답안 #387606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
387606 2021-04-09T03:42:50 Z 2qbingxuan Trampoline (info1cup20_trampoline) C++14
0 / 100
472 ms 71084 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 = [&x, &to, &y](int i, int limx) {
        for (int L = LG-1; L >= 0; L--) {
            if (x[to[i][i]] <= limx)
                i = to[i][L];
        }
        return y[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 (!mp.count(srcx)) {
            debug("CASE1");
            answer(srcx == destx && srcy <= desty);
        } else {
            auto it = lower_bound(all(mp[srcx]), make_pair(srcy, 0));
            if (it == mp[srcx].end()) {
                debug("CASE2");
                answer(srcx == destx && srcy <= desty);
            } else {
                debug("CASE3");
                int y = go(it->second, destx);
                answer (y <= desty);
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1484 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 219 ms 56916 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 169 ms 54824 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1020 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 472 ms 71084 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -