답안 #892934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892934 2023-12-26T07:53:23 Z Xiaoyang Trampoline (info1cup20_trampoline) C++17
100 / 100
1010 ms 84816 KB
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cout<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 1ll<<60
#define rep(i,a,b) for (ll i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
#define endl "\n"
void inc(ll &a,ll b) {a=(a+b)%mod;}
void dec(ll &a,ll b) {a=(a-b+mod)%mod;}
int prod(ll a,ll b) {return ll(a)*ll(b)%mod;}
int lowbit(ll x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

const ll lg=22;
const ll maxn=2e5+5;
ll twok[maxn][lg];
ll row[maxn],col[maxn];
map<ll,vector<ll>>mp;
map<pll,ll>id;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll r,c,n;cin>>r>>c>>n;
    rep(i,1,n+1){
        cin>>row[i]>>col[i];
        mp[row[i]].pb(col[i]);
        id[MP(row[i],col[i])]=i;
    }
    for(auto x:mp){
        sort(ALL(mp[x.fi]));
        //for(auto y:mp[x.fi])cout<<y<<" ";
        //cout<<endl;
    }
    
    rep(i,1,n+1){
        auto it=lower_bound(ALL(mp[row[i]+1]),col[i]);
        if(it==mp[row[i]+1].end())continue;
        twok[i][0]=id[MP(row[i]+1,*it)];
    }
    rep(j,1,lg){
        rep(i,1,n+1){
            twok[i][j]=twok[twok[i][j-1]][j-1];
        }
    }
    /*
    rep(i,1,n+1){
        rep(j,0,lg){
            cout<<twok[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    ll t;cin>>t;
    while(t--){
        ll x,y,xx,yy;
        cin>>x>>y>>xx>>yy;
        ll diff=xx-x;
        if(xx<x or yy<y)cout<<"No"<<endl;
        else if(diff==0)cout<<"Yes"<<endl;
        else{
            ll u;
            auto it=lower_bound(ALL(mp[x]),y);
            if(it==mp[x].end())u=0;
            else u=id[MP(x,*it)];
            diff--;
            rep(i,0,lg){
                if(diff&(1<<i)){
                    u=twok[u][i];
                }
            }
            if(u==0 or col[u]>yy)cout<<"No"<<endl;
            else cout<<"Yes"<<endl;
        }
    }
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7260 KB 200 token(s): yes count is 21, no count is 179
2 Correct 8 ms 7260 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 7232 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 317 ms 53584 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 320 ms 54100 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 302 ms 53332 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 310 ms 54100 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 387 ms 53044 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 431 ms 59528 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 484 ms 59432 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 514 ms 59728 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 501 ms 59904 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 651 ms 66136 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4956 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 5324 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 10 ms 4956 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 6 ms 5208 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 5212 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 5212 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 833 ms 61176 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 665 ms 67668 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 478 ms 64720 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1010 ms 84816 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 603 ms 71600 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 514 ms 65600 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 568 ms 65624 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 465 ms 64768 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 781 ms 71508 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 801 ms 71760 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 927 ms 77476 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 375 ms 65112 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 416 ms 64784 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 604 ms 65612 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 426 ms 64804 KB 200000 token(s): yes count is 129674, no count is 70326