답안 #775786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775786 2023-07-07T00:22:35 Z HD1 Trampoline (info1cup20_trampoline) C++14
100 / 100
977 ms 89108 KB
//we are all lost trying to be someone.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define reve(x) reverse(x.begin(),x.end())
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<double,ll> ii;
const ll MAX=(1e5+10)*2;
const ll mod=1e9+7;
map<ii,ll>nod;
map<ll, vector<ll>> V;
ll x[MAX], y[MAX];
ll spt[30][MAX];
ll up(ll a, ll b){
    auto it = lower_bound( all(V[a]), b);
    if(it == V[a].end()) return 0;
    return nod[{a,*it}];
}
void solve(){
        ll n , m, k;
        cin >> n >> m >> k;
 
        for(ll i = 1; i <= k; i++){
            cin >> x[i] >> y[i];
            nod[ {x[i] , y[i] } ] =i;
            V[ x[i] ].push_back( y[i] );
        }
 
        for(auto &it : V)  sort( it.ss.begin(), it.ss.end());
 
        for(ll i = 1; i <= k; i++) spt[0][i] = up(x[i]+1 , y[i]);
 
        for(ll j = 1; j < 30; j++){
            for(ll i = 1; i <=k; i++){
                spt[j][i] = spt[j-1][spt[j-1][i]];
            }
        }
        ll x1, y1, x2, y2;
        ll t;
        cin >> t;
        while( t--){
            cin >> x1 >> y1 >> x2 >> y2;
 
            ll dist = x2 - x1;
            if(x1 > x2 || y1 > y2) cout << "No\n" ;
            else if(dist == 0)cout << "Yes\n";
            else{
                    ll u=up(x1,y1);
                    dist--;
                    for(ll i = 0; i < 30; i++){
                        if((dist >> i) & 1){
                           u = spt[i][u];
                        }
                    }
                    if(u != 0 && y[u] <= y2)
                            cout<<"Yes\n";
                    else
                            cout<<"No\n";
 
            }
 
        }
        return;
}
int main(){
    fastio;
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3412 KB 200 token(s): yes count is 21, no count is 179
2 Correct 8 ms 3748 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 2772 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 288 ms 66512 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 287 ms 67716 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 267 ms 66540 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 302 ms 67756 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 357 ms 65144 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 385 ms 66896 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 393 ms 66892 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 501 ms 68040 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 469 ms 67968 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 644 ms 74072 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2132 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 2132 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 9 ms 3028 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 6 ms 2132 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 2260 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 2132 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 819 ms 73468 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 746 ms 71964 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 476 ms 68940 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 977 ms 89108 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 633 ms 76004 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 508 ms 69312 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 477 ms 69300 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 439 ms 68792 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 790 ms 75788 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 804 ms 76252 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 945 ms 81800 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 355 ms 68708 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 376 ms 68812 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 559 ms 69592 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 381 ms 68784 KB 200000 token(s): yes count is 129674, no count is 70326