Submission #675218

# Submission time Handle Problem Language Result Execution time Memory
675218 2022-12-27T03:05:51 Z vjudge1 Trampoline (info1cup20_trampoline) C++17
100 / 100
289 ms 18368 KB
#include<bits/stdc++.h>
using namespace std;
int r,c,n,t;
pair <int,int> a[200100];
int nxt[20][200100];
void out(bool x){
    if (x)cout<<"Yes";
    else cout<<"No";
    cout<<'\n';
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
    cin>>r>>c>>n;
    for (int i = 1;i <= n;i ++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a+1,a+1+n);
    for (int i = 1;i <= n;i ++){
        nxt[0][i] = lower_bound(a+1,a+1+n,make_pair(a[i].first + 1,a[i].second)) - (a);
        if (a[nxt[0][i]].first != a[i].first + 1)nxt[0][i] = n + 1;
    }
    nxt[0][n+1] = n+1;
    for (int j = 1;j < 20;j ++){
        for (int i = 1;i <= n+1;i ++){
            nxt[j][i] = nxt[j-1][nxt[j-1][i]];
        }
    }
    cin>>t;
    while (t--){
        int xs,ys,xe,ye;
        cin>>xs>>ys>>xe>>ye;
        int cur = lower_bound(a+1,a+1+n,make_pair(xs,ys)) - (a);
        if (xs == xe){
            out(ys <= ye);
        }
        else{
            if (xs < xe){
                int k = xe - xs - 1;
                for (int j = 19;j >= 0;j --){
                    if ((1<<j) <= k){
                        k -= (1<<j);
                        cur = nxt[j][cur];
                    }
                }
                out(a[cur].first == xe - 1 && a[cur].second <= ye);
            }
            else{
                out(0);
            }
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1108 KB 200 token(s): yes count is 21, no count is 179
2 Correct 3 ms 1236 KB 200 token(s): yes count is 70, no count is 130
3 Correct 2 ms 980 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 65 ms 17452 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 65 ms 17496 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 62 ms 17540 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 64 ms 17496 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 202 ms 18288 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 185 ms 18196 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 192 ms 18236 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 198 ms 18128 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 185 ms 18216 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 183 ms 18124 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 7 ms 852 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 5 ms 852 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 5 ms 876 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 5 ms 852 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 5 ms 852 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 5 ms 880 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 240 ms 18292 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 280 ms 18252 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 197 ms 18184 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 289 ms 18200 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 221 ms 18212 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 195 ms 18260 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 215 ms 18268 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 212 ms 18168 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 266 ms 18368 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 252 ms 18332 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 262 ms 18256 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 188 ms 18272 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 213 ms 18200 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 206 ms 18188 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 184 ms 18272 KB 200000 token(s): yes count is 129674, no count is 70326