Submission #335000

# Submission time Handle Problem Language Result Execution time Memory
335000 2020-12-10T17:56:19 Z Sho10 Trampoline (info1cup20_trampoline) C++14
100 / 100
518 ms 63212 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,k,dp[200005][30];
pair<ll,ll>a[200005];
ll calc(ll x,ll y){
ll l=1,r=k,ans=k+1;
while(l<=r){
    ll mid=(l+r)>>1;
    if(a[mid]>=mp(x,y)){
        ans=mid;
        r=mid-1;
    }else l=mid+1;
}
if(ans==k+1||a[ans].f>x){
    return 0;
}else return ans;
}
int32_t main(){
CODE_START;
cin>>n>>m>>k;
for(ll i=1;i<=k;i++)
{
    cin>>a[i].f>>a[i].s;
}
a[0]=mp(LINF,LINF);
sort(a+1,a+k+1);
for(ll i=1;i<=k;i++)
{
    dp[i][0]=calc(a[i].f+1,a[i].s);
}
for(ll j=1;j<30;j++)
{
    for(ll i=1;i<=k;i++)
    {
        dp[i][j]=dp[dp[i][j-1]][j-1];
    }
}
ll q;
cin>>q;
while(q--){
    ll x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    if(x1>x2||y1>y2){
        cout<<"No"<<endl;
    }else if(x1==x2){
    cout<<"Yes"<<endl;
    }else {
    ll i=calc(x1,y1),d=x2-x1-1;
    for(ll j=0;j<30;j++)
    {
        if(d&(1<<j)){
            i=dp[i][j];
        }
    }
    if(a[i].s<=y2){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
    }
}
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 2668 KB 200 token(s): yes count is 21, no count is 179
2 Correct 6 ms 2924 KB 200 token(s): yes count is 70, no count is 130
3 Correct 4 ms 2176 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 176 ms 52472 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 174 ms 52384 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 168 ms 51948 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 173 ms 52332 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 317 ms 62828 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 325 ms 63056 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 360 ms 62828 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 347 ms 63168 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 331 ms 62828 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 335 ms 62828 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1900 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 1900 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 7 ms 1976 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 7 ms 1900 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 2028 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 7 ms 1900 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 488 ms 63024 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 473 ms 62828 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 362 ms 63212 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 515 ms 62828 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 397 ms 62828 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 381 ms 63212 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 375 ms 62956 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 356 ms 62956 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 478 ms 62956 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 492 ms 62828 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 518 ms 62956 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 326 ms 62956 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 329 ms 62956 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 422 ms 63084 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 331 ms 62956 KB 200000 token(s): yes count is 129674, no count is 70326