답안 #387609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
387609 2021-04-09T03:52:52 Z 2qbingxuan Trampoline (info1cup20_trampoline) C++14
11 / 100
1139 ms 35936 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);
    }
    for (auto &[x, ys]: mp)
        sort(all(ys));
    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);
            }
        }
    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:34:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   34 |     for (auto &[x, ys]: mp)
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1484 KB 200 token(s): yes count is 21, no count is 179
2 Incorrect 7 ms 1708 KB expected YES, found NO [69th token]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 220 ms 28148 KB expected YES, found NO [803rd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 307 ms 27832 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 331 ms 27784 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 348 ms 28040 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 428 ms 28504 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 444 ms 28448 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 762 ms 34608 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 976 KB expected YES, found NO [42nd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1139 ms 35936 KB expected YES, found NO [11404th token]
2 Halted 0 ms 0 KB -