답안 #522891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522891 2022-02-06T10:11:41 Z Savu_Stefan_Catalin Trampoline (info1cup20_trampoline) C++14
100 / 100
278 ms 18572 KB
#include <iostream>
#include <algorithm>
using namespace std;
int n,t[25][200005],xs,ys,xf,yf,i,j,test,st;
pair<int,int> s[200005];
int cb(int x,int y)
{
    int st=1,dr=n,mij=0,ras=0;
    while (st<=dr)
    {
        mij=(st+dr)/2;
        if (s[mij].first>x) {dr=mij-1;}
        else if (s[mij].first<x) {st=mij+1;}
        else if (s[mij].second<y) {st=mij+1;}
        else {dr=mij-1; ras=mij;}
    }
    return ras;
}
int ascen(int nod,int lvl)
{
    for (int i=19;i>=0;--i)
    {
        if ((1<<i)<=lvl)
        {
            nod=t[i][nod];
            lvl-=(1<<i);
        }
    }
    if (nod==0) return 2000000000;
    return s[nod].second;
}
int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>n>>n;
    for (i=1;i<=n;++i)
    {
        cin>>s[i].first>>s[i].second;
    }
    sort(s+1,s+n+1);
    for (i=1;i<=n;++i)
    {
        t[0][i]=cb(s[i].first+1,s[i].second);
    }
    for (i=1;i<=19;++i)
    {
        for (j=1;j<=n;++j)
        t[i][j]=t[i-1][t[i-1][j]];
    }
    cin>>test;
    for (i=1;i<=test;++i)
    {
        cin>>xs>>ys>>xf>>yf;
        if (xs==xf) {if (ys<=yf) {cout<<"Yes"<<'\n';} else {cout<<"No"<<'\n';} continue;}
        if (xf<xs||yf<ys) {cout<<"No"<<'\n'; continue;}
        st=cb(xs,ys);
        if (st==0) {cout<<"No";}
        else if (ascen(st,xf-1-xs)<=yf) {cout<<"Yes";}
        else {cout<<"No";}
        cout<<'\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1228 KB 200 token(s): yes count is 21, no count is 179
2 Correct 4 ms 1356 KB 200 token(s): yes count is 70, no count is 130
3 Correct 3 ms 1100 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 17664 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 66 ms 17740 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 77 ms 17816 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 73 ms 17728 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 179 ms 18396 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 202 ms 18456 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 192 ms 18404 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 184 ms 18372 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 226 ms 18572 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 185 ms 18392 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 972 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 5 ms 1100 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 6 ms 1100 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 5 ms 1100 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 6 ms 1104 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 5 ms 1100 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 18544 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 270 ms 18508 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 189 ms 18476 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 260 ms 18500 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 235 ms 18476 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 194 ms 18452 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 204 ms 18500 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 196 ms 18500 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 246 ms 18508 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 278 ms 18560 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 277 ms 18352 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 180 ms 18360 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 197 ms 18328 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 218 ms 18388 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 179 ms 18252 KB 200000 token(s): yes count is 129674, no count is 70326