Submission #753110

# Submission time Handle Problem Language Result Execution time Memory
753110 2023-06-04T15:42:31 Z DJeniUp Trampoline (info1cup20_trampoline) C++17
100 / 100
1756 ms 87672 KB
#include "bits/stdc++.h"
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O3")
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,ull>pairull;
typedef pair<ll,pairll>pair3l;
typedef long double ld;
typedef pair<ld,ll>pairld;
 
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define N 100007
//#define MOD 998244353
#define INF 100000000000007
#define eps 0.0000000001
 
ll n,m,k,h,p[36][2*N];
 
struct D{
    ll l,r;
}d[2*N];
 
map<ll,ll>mp;
 
vector<pairll>v[2*N];
 
bool mcp(D d1, D d2){
    if(d1.l!=d2.l)return d1.l<d2.l;
    return d1.r<d2.r;
}
 
ll P(ll x,ll y){
    for(int i=30;i>=0;i--){
        ll g=p[i][x];
        if(d[g].l<y)x=g;
    }
    return x;
}
 
int main(){
    
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++){
        cin>>d[i].l>>d[i].r;
    }
    sort(d+1,d+1+k,mcp);
    for(int i=1;i<=k;i++){
        if(d[i].l!=d[i-1].l){
            h++;
            mp[d[i].l]=h;
        }
        v[h].pb({d[i].r,i});
    }
    for(int i=1;i<=k;i++){
        if(mp[d[i].l+1]==0){
            p[0][i]=k+1;
        }else{
            ll l=0;
            ll nm=mp[d[i].l+1];
            ll r=v[nm].size();
            while(l<r){
                ll m1=(l+r)/2;
                if(v[nm][m1].fr>=d[i].r)r=m1;
                else l=m1+1;
            }
            if(r==v[nm].size())p[0][i]=k+1;
            else p[0][i]=v[nm][r].sc;
        }
    }
    p[0][k+1]=k+1;
    for(int i=1;i<=30;i++){
        for(int j=1;j<=k+1;j++){
            p[i][j]=p[i-1][p[i-1][j]];
        }
    }
    d[k+1].l=INF;
    ll q;
    cin>>q;
    for(int i=1;i<=q;i++){
        ll x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if(y1>y2 || x1>x2){
            cout<<"No"<<endl;
        }
        else if(x1==x2){
            cout<<"Yes"<<endl;
        }else{
            if(mp[x1]==0){
                cout<<"No"<<endl;
                continue;
            }
            ll l=0;
            ll nm=mp[x1];
            ll r=v[nm].size();
            while(l<r){
                ll m1=(l+r)/2;
                if(v[nm][m1].fr>=y1){
                    r=m1;
                }else l=m1+1;
            }
            h=0;
            if(r==v[nm].size())h=k+1;
            else h=v[nm][r].sc;
            h=P(h,x2);
            if(d[h].l==x2-1 && d[h].r<=y2)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
 
    return 0;
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:73:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |             if(r==v[nm].size())p[0][i]=k+1;
      |                ~^~~~~~~~~~~~~~
trampoline.cpp:109:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  109 |             if(r==v[nm].size())h=k+1;
      |                ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 7676 KB 200 token(s): yes count is 21, no count is 179
2 Correct 15 ms 7948 KB 200 token(s): yes count is 70, no count is 130
3 Correct 8 ms 7228 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 176 ms 61744 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 222 ms 61684 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 157 ms 60736 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 180 ms 61716 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 1274 ms 61536 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 1291 ms 61352 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 1304 ms 60724 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 1594 ms 61848 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 1582 ms 61920 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 1674 ms 66308 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 28 ms 6612 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 25 ms 6932 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 28 ms 7508 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 23 ms 6936 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 30 ms 7040 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 35 ms 6936 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 1697 ms 67280 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 1580 ms 63276 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 1346 ms 72612 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1756 ms 87672 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 1551 ms 78016 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 1432 ms 73304 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 1532 ms 73328 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 1310 ms 72404 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 1714 ms 77944 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1750 ms 78072 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1745 ms 82572 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 1256 ms 72572 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 1213 ms 73200 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 1436 ms 73780 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 1238 ms 73424 KB 200000 token(s): yes count is 129674, no count is 70326