답안 #1087036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087036 2024-09-12T05:59:10 Z TrinhKhanhDung Trampoline (info1cup20_trampoline) C++14
0 / 100
382 ms 37976 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(x) (int)x.size()
#define ALL(v) v.begin(),v.end()
#define MASK(k) (1LL << (k))
#define BIT(x, i) (((x) >> (i)) & 1)
#define oo (ll)1e18
#define INF (ll)1e9
#define MOD (ll)(1007050321)

using namespace std;

template<class T1, class T2>
    bool maximize(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

template<class T1, class T2>
    bool minimize(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}

template<class T1, class T2>
    void add(T1 &a, T2 b){a += b; if(a >= MOD) a -= MOD;}

template<class T1, class T2>
    void sub(T1 &a, T2 b){a -= b; if(a < 0) a += MOD;}

template<class T>
    void cps(T &v){sort(ALL(v)); v.resize(unique(ALL(v)) - v.begin());}

const int MAX = 2e5 + 10, LOG = 18;

int R, C, N, Q;
int d[MAX][LOG];
int X[MAX], Y[MAX];

void solve(){
    cin >> R >> C >> N;
    map<int, vector<pair<int, int>>> mp;
    for(int i = 1; i <= N; i++){
        int x, y;
        cin >> x >> y;
        X[i] = x; Y[i] = y;
        mp[x].push_back(make_pair(y, i));
    }
    for(auto o: mp){
        sort(ALL(o.se));
    }
    for(int i = 1; i <= N; i++){
        if(!mp.count(X[i] + 1)) continue;
        auto it = lower_bound(ALL(mp[X[i] + 1]), make_pair(Y[i], 0));
        if(it != mp[X[i] + 1].end()){
            d[i][0] = it->se;
        }
    }

    for(int j = 1; j < LOG; j++){
        for(int i = 1; i <= N; i++){
            d[i][j] = d[d[i][j - 1]][j - 1];
        }
    }

    cin >> Q;
    while(Q--){
        int x, y, u, v; cin >> x >> y >> u >> v;
        if(u < x){
            cout << "No\n";
            continue;
        }
        if(x == u){
            cout << (v >= y ? "Yes\n" : "No\n");
            continue;
        }
        auto it = lower_bound(ALL(mp[x]), make_pair(y, 0));
        if(it == mp[x].end()){
            cout << "No\n";
            continue;
        }
        int c = it->se;
        int delta = u - x - 1;
        for(int i = 0; i < LOG; i++) if(BIT(delta, i)){
            c = d[c][i];
        }

//        cout << c << ' ';

        if(c != 0 && Y[c] <= v) cout << "Yes\n";
        else cout << "No\n";
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
//    freopen("numtable.inp","r",stdin);
//    freopen("numtable.out","w",stdout);

    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1528 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 117 ms 20884 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 130 ms 30816 KB expected YES, found NO [4th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1116 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 382 ms 37976 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -