Submission #753065

# Submission time Handle Problem Language Result Execution time Memory
753065 2023-06-04T14:10:44 Z DJeniUp Trampoline (info1cup20_trampoline) C++17
54 / 100
1570 ms 62884 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,g[2*N],p[26][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=20;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++;
            g[h]=d[i].l;
            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<=20;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(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;
            }
            ll h=0;
            if(r==v[nm].size())r=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:74: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]
   74 |             if(r==v[nm].size())p[0][i]=k+1;
      |                ~^~~~~~~~~~~~~~
trampoline.cpp:107: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]
  107 |             if(r==v[nm].size())r=k+1;
      |                ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 6868 KB 200 token(s): yes count is 21, no count is 179
2 Correct 10 ms 7244 KB 200 token(s): yes count is 70, no count is 130
3 Correct 8 ms 6560 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 199 ms 46128 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 156 ms 48036 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 146 ms 46500 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 188 ms 48044 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 1187 ms 45820 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 1250 ms 57292 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 1334 ms 56692 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 1486 ms 58004 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 1446 ms 57952 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 1570 ms 62884 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 6228 KB expected NO, found YES [16th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1454 ms 52356 KB 200000 token(s): yes count is 171404, no count is 28596
2 Incorrect 1533 ms 59360 KB expected NO, found YES [22020th token]
3 Halted 0 ms 0 KB -