답안 #276942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
276942 2020-08-20T20:46:49 Z thebes Trampoline (info1cup20_trampoline) C++14
100 / 100
1165 ms 57312 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> pii;
#define F first
#define S second

const int MN = 2e5+5, LG = 19;
int R, C, N, T, i, j, x, y, a, b, s, t, sp[LG][MN], nxt, rev[MN];
map<int,int> mp, st[MN];
pii pnt[MN];

int main(){
    scanf("%d%d%d",&R,&C,&N);
    for(i=1;i<=N;i++){
        scanf("%d%d",&x,&y);
        pnt[i]={x,y};
        mp[x] = 0;
    }
    for(auto it=mp.begin();it!=mp.end();it++)
        it->second = ++nxt, rev[nxt] = it->first;
    for(i=1;i<=N;i++)
        st[mp[pnt[i].F]][pnt[i].S]=i;
    for(i=1;i<=N;i++){
        x = mp[pnt[i].F];
        if(rev[x]+1==rev[x+1]){
            auto it=st[x+1].lower_bound(pnt[i].S);
            if(it!=st[x+1].end()){
                sp[0][i]=it->S;
            }
        }
    }
    for(j=1;j<LG;j++){
        for(i=1;i<=N;i++){
            if(sp[j-1][i]&&sp[j-1][sp[j-1][i]])
                sp[j][i]=sp[j-1][sp[j-1][i]];
        }
    }
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d%d",&x,&y,&a,&b);
        if(x==a) printf("%s\n",y<=b?"Yes":"No");
        else{
            s = t = 0;
            auto it=st[mp[x]].lower_bound(y);
            if(it!=st[mp[x]].end()) s = it->S;
            it=st[mp[a-1]].upper_bound(b);
            if(it!=st[mp[a-1]].begin()&&st[mp[a-1]].size()){
                it--;
                t = it->S;
            }
            if(!s||!t) printf("No\n");
            else{
                int dis = a-x-1;
                for(j=LG-1;j>=0;j--){
                    if(dis&(1<<j)) s = sp[j][s];
                }
                if(!s) printf("No\n");
                else if(pnt[s].F==pnt[t].F&&pnt[s].S<=pnt[t].S) printf("Yes\n");
                else printf("No\n");
            }
        }
    }
    return 0;
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d%d%d",&R,&C,&N);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
trampoline.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
trampoline.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   39 |     scanf("%d",&T);
      |     ~~~~~^~~~~~~~~
trampoline.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         scanf("%d%d%d%d",&x,&y,&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 10624 KB 200 token(s): yes count is 21, no count is 179
2 Correct 15 ms 10624 KB 200 token(s): yes count is 70, no count is 130
3 Correct 13 ms 10368 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 312 ms 28152 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 319 ms 28152 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 313 ms 29484 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 310 ms 32124 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 571 ms 35576 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 620 ms 37204 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 604 ms 36984 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 700 ms 41828 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 766 ms 41936 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 905 ms 49656 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 10496 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 17 ms 10496 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 18 ms 10624 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 15 ms 10400 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 18 ms 10624 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 15 ms 10368 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 1010 ms 50468 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 1027 ms 46084 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 717 ms 37112 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1161 ms 57312 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 878 ms 50284 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 653 ms 37200 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 663 ms 37112 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 690 ms 37240 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 1090 ms 49812 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1165 ms 49780 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1141 ms 53880 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 577 ms 34816 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 617 ms 35576 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 755 ms 41848 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 621 ms 35788 KB 200000 token(s): yes count is 129674, no count is 70326