답안 #920917

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920917 2024-02-03T07:37:38 Z salmon Trampoline (info1cup20_trampoline) C++14
100 / 100
1080 ms 73296 KB
#include <bits/stdc++.h>
using namespace std;

int R,C;
map<int,set<int>> mep;
pair<int,int> tramp[200100];
map<pair<int,int>,int> de;
int N;
int T;
int h,h1;
int parent[200100][30];
int e,e1;

int main(){
    scanf(" %d",&R);
    scanf(" %d",&C);

    scanf(" %d",&N);

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= 29; j++){
            parent[i][j] = -1;
        }
    }

    for(int i = 0; i < N; i++){
        scanf(" %d",&h);
        scanf(" %d",&h1);
        mep[h].insert(h1);
        de[{h,h1}] = i;
        tramp[i] = {h,h1};
    }

    for(int i = 0; i < N; i++){
        if(mep.find(tramp[i].first + 1) != mep.end()){
            if(mep[tramp[i].first + 1].lower_bound(tramp[i].second) != mep[tramp[i].first + 1].end()){
                parent[i][0] = de[{tramp[i].first + 1, *mep[tramp[i].first + 1].lower_bound(tramp[i].second)}] ;
            }
        }
    }

    for(int j = 0; j < 25; j++){
        for(int i = 0; i < N; i++){
            if(parent[i][j] != -1){
                parent[i][j + 1] =  parent[parent[i][j]][j];
            }
        }
    }

    /*for(int i =0; i < N; i++){
        for(int j = 0; j < 3; j++){
            printf("%d ",parent[i][j]);
        }
        printf("\n");
    }*/

    scanf(" %d",&T);

    for(int i = 0; i < T; i++){
        scanf(" %d",&h);
        scanf(" %d",&h1);

        scanf(" %d",&e);
        scanf(" %d",&e1);

        if(e < h || e1 < h1){
            printf("No\n");
            continue;
        }

        if(h == e){
            printf("Yes\n");
        }
        else{
            if(mep.find(h) == mep.end()){
                printf("No\n");
            }
            else{
                if(mep[h].lower_bound(h1) == mep[h].end()){
                    printf("No\n");
                    continue;
                }
                int j = *mep[h].lower_bound(h1);
                j = de[{h,j}];

                int i = 25;
                while(i != -1){
                    if(parent[j][i] != -1 && tramp[parent[j][i]].first <= e - 1){
                        j = parent[j][i];
                    }
                    i--;
                }
                //printf("%d\n",tramp[j].first);
                if(tramp[j].first == e - 1){
                    if(tramp[j].second <= e1) printf("Yes\n");
                    else printf("No\n");
                }
                else{
                    printf("No\n");
                }
            }
        }
    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf(" %d",&R);
      |     ~~~~~^~~~~~~~~~
trampoline.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf(" %d",&C);
      |     ~~~~~^~~~~~~~~~
trampoline.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf(" %d",&N);
      |     ~~~~~^~~~~~~~~~
trampoline.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf(" %d",&h);
      |         ~~~~~^~~~~~~~~~
trampoline.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf(" %d",&h1);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:57:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |     scanf(" %d",&T);
      |     ~~~~~^~~~~~~~~~
trampoline.cpp:60:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |         scanf(" %d",&h);
      |         ~~~~~^~~~~~~~~~
trampoline.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         scanf(" %d",&h1);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:63:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         scanf(" %d",&e);
      |         ~~~~~^~~~~~~~~~
trampoline.cpp:64:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         scanf(" %d",&e1);
      |         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 5468 KB 200 token(s): yes count is 21, no count is 179
2 Correct 11 ms 5804 KB 200 token(s): yes count is 70, no count is 130
3 Correct 7 ms 5468 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 479 ms 47700 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 441 ms 49232 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 431 ms 48764 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 443 ms 49420 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 545 ms 52716 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 587 ms 54492 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 667 ms 54636 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 772 ms 54784 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 814 ms 54752 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 895 ms 60928 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5212 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 9 ms 5448 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 9 ms 5980 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 8 ms 5468 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 10 ms 5468 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 7 ms 5468 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 1020 ms 59984 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 864 ms 56336 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 616 ms 54868 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1074 ms 73296 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 770 ms 61132 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 666 ms 54372 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 646 ms 54360 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 623 ms 54664 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 1014 ms 60692 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1008 ms 60848 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1080 ms 67252 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 495 ms 54612 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 526 ms 54356 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 755 ms 54556 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 577 ms 54780 KB 200000 token(s): yes count is 129674, no count is 70326