답안 #1087038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087038 2024-09-12T06:07:01 Z TrinhKhanhDung Trampoline (info1cup20_trampoline) C++14
100 / 100
516 ms 50200 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 Correct 3 ms 1372 KB 200 token(s): yes count is 21, no count is 179
2 Correct 4 ms 1372 KB 200 token(s): yes count is 70, no count is 130
3 Correct 3 ms 1116 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 20880 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 117 ms 20820 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 98 ms 19764 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 115 ms 20820 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 30660 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 173 ms 30388 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 180 ms 30544 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 243 ms 31060 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 236 ms 31312 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 340 ms 36772 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1116 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 4 ms 1116 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 5 ms 1628 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 5 ms 1236 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 6 ms 1372 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 4 ms 1116 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 441 ms 38220 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 339 ms 33064 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 192 ms 30716 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 516 ms 50200 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 290 ms 37216 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 184 ms 30648 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 178 ms 30680 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 192 ms 30396 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 384 ms 36948 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 435 ms 37072 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 480 ms 42836 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 155 ms 30176 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 158 ms 30536 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 235 ms 31056 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 161 ms 30236 KB 200000 token(s): yes count is 129674, no count is 70326