답안 #675372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
675372 2022-12-27T06:55:43 Z baokhue232005 Trampoline (info1cup20_trampoline) C++14
11 / 100
468 ms 91044 KB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
// lethal option

#include<bits/stdc++.h>
using namespace std;

#define all(flg) flg.begin(), flg.end()
#define int long long
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define eb emplace_back
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define PI 3.141592653589793238462643383279502884
#define ll long long
#define ld long double
#define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
#define for2(i, ff, gg) for(int i = ff; i >= gg; --i)
const ll mod = 1e9 + 7;
const int maxN = 300005;
const ll oo = 1e18 + 7;
int n, a[maxN];
int x, y, z, k;

map<int, vii> mp;

int jp[maxN][32];
int h[maxN], pl[maxN];

signed main(){
    // freopen(".inp", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> x >> x >> n;
    for1(i, 1, n){
        cin >> x >> y;
        mp[x].pb(ii(y, i));
        h[i] = x;
        pl[i] = y;
    }
    memset(jp, 0, sizeof(jp));
    for(auto &pr : mp){
        sort(all(pr.se));
        if(mp.find(pr.fi + 1) == mp.end()) continue;
        vii &cac = mp[pr.fi + 1];
        for(ii cc : pr.se){
            int id = lower_bound(all(cac), ii(cc.fi, -oo))
                - cac.begin();
            if(id == cac.size()) continue;
            jp[cc.se][0] = cac[id].se;
        }
    }
    for1(ds, 0, 25){
        for1(i, 0, n){
            jp[i][ds + 1] = jp[jp[i][ds]][ds];
        }
    }
    int o; cin >> o; while(o--){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(x1 >= x2){
            if(y1 <= y2 && x1 == x2) cout << "Yes\n";
            else cout << "No\n";
            continue;
        }
        vii &cac = mp[x1];
        int id = lower_bound(all(cac), ii(y1, -oo)) - cac.begin();
        if(id == cac.size()){
            cout << "No\n"; continue;
        }
        id = cac[id].se;
        int mask = x2 - x1 - 1;
        for2(i, 25, 0) if(mask & (1 << i)){
            id = jp[id][i];
        }
        if(id && pl[id] <= y2) cout << "Yes\n";
        else cout << "No\n";
        // cout << id << endl;
    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:57:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             if(id == cac.size()) continue;
      |                ~~~^~~~~~~~~~~~~
trampoline.cpp:76:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         if(id == cac.size()){
      |            ~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 75788 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 84448 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 83852 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 251 ms 83128 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 257 ms 83120 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 292 ms 84496 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 270 ms 84572 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 388 ms 89872 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 75604 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 468 ms 91044 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -