답안 #442734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
442734 2021-07-08T19:19:43 Z JovanB Trampoline (info1cup20_trampoline) C++17
100 / 100
972 ms 50192 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

map <int, int> comp;

const int MAXN = 200000;

vector <pair <int, int>> vec[MAXN+5];
int rev[MAXN+5];

const int MXLOG = 18;

int jmp[MAXN+5][MXLOG+1];

const int INF = 1000000007;

int pi[MAXN+5];
int pj[MAXN+5];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int R, C;
    cin >> R >> C;
    int n;
    cin >> n;
    int tjm = 0;
    for(int i=1; i<=n; i++){
        cin >> pi[i] >> pj[i];
        if(!comp[pi[i]]){
            comp[pi[i]] = ++tjm;
            rev[tjm] = pi[i];
        }
        vec[comp[pi[i]]].push_back({pj[i], i});
    }
    pi[n+1] = INF;
    pj[n+1] = INF;
    jmp[n+1][0] = n+1;
    for(int i=1; i<=tjm; i++) sort(vec[i].begin(), vec[i].end());
    for(int i=1; i<=tjm; i++){
        int sled = comp[rev[i] + 1];
        for(auto c : vec[i]) jmp[c.second][0] = n+1;
        if(sled == 0) continue;
        for(auto v : vec[i]){
            auto p = lower_bound(vec[sled].begin(), vec[sled].end(), make_pair(v.first, 0));
            if(p != vec[sled].end()) jmp[v.second][0] = p->second;
        }
    }
    for(int j=1; j<=MXLOG; j++){
        for(int i=1; i<=n+1; i++){
            jmp[i][j] = jmp[jmp[i][j-1]][j-1];
        }
    }
    int qrs;
    cin >> qrs;
    while(qrs--){
        int si, sj, ti, tj;
        cin >> si >> sj >> ti >> tj;
        if(si == ti){
            cout << (sj <= tj ? "Yes" : "No") << "\n";
            continue;
        }
        int g = comp[si];
        if(!g){
            cout << "No\n";
            continue;
        }
        auto p = lower_bound(vec[g].begin(), vec[g].end(), make_pair(sj, 0));
        if(p == vec[g].end()){
            cout << "No\n";
            continue;
        }
        int poc = p->second;
        for(int j=MXLOG; j>=0; j--){
            if(pi[jmp[poc][j]] < ti) poc = jmp[poc][j];
        }
        cout << (pj[poc] <= tj && pi[poc] == ti-1 ? "Yes" : "No") << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5836 KB 200 token(s): yes count is 21, no count is 179
2 Correct 7 ms 6092 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 5708 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 141 ms 24464 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 143 ms 26232 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 129 ms 25292 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 138 ms 26220 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 347 ms 24252 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 346 ms 24120 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 422 ms 24248 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 392 ms 24736 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 413 ms 24784 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 615 ms 28844 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 5452 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 10 ms 5836 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 13 ms 6348 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 10 ms 5796 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 13 ms 5924 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 11 ms 5708 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 825 ms 29876 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 600 ms 38052 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 386 ms 36080 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 972 ms 50192 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 588 ms 40536 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 383 ms 36020 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 379 ms 35992 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 378 ms 35828 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 738 ms 40452 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 807 ms 40808 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 904 ms 44672 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 335 ms 35628 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 376 ms 36024 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 425 ms 36500 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 344 ms 35652 KB 200000 token(s): yes count is 129674, no count is 70326