Submission #920907

# Submission time Handle Problem Language Result Execution time Memory
920907 2024-02-03T07:33:06 Z salmon Trampoline (info1cup20_trampoline) C++14
57 / 100
1231 ms 73052 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 <= 25; 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()){
            parent[i][0] = de[pair<int,int>{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:55:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     scanf(" %d",&T);
      |     ~~~~~^~~~~~~~~~
trampoline.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         scanf(" %d",&h);
      |         ~~~~~^~~~~~~~~~
trampoline.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |         scanf(" %d",&h1);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         scanf(" %d",&e);
      |         ~~~~~^~~~~~~~~~
trampoline.cpp:62:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         scanf(" %d",&e1);
      |         ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5464 KB expected NO, found YES [31st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 434 ms 47700 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 522 ms 47928 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 615 ms 54248 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 667 ms 54360 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 706 ms 54356 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 714 ms 54344 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 841 ms 60344 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 8 ms 5208 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 9 ms 5468 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 5488 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 7 ms 5464 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 998 ms 57924 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 838 ms 56144 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 633 ms 54516 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1125 ms 73052 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 853 ms 60900 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 851 ms 54292 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 723 ms 54088 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 647 ms 54104 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 1176 ms 60540 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1130 ms 60576 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1231 ms 66916 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 602 ms 54612 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 591 ms 54304 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 858 ms 54420 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 632 ms 54216 KB 200000 token(s): yes count is 129674, no count is 70326