답안 #426828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426828 2021-06-14T10:12:07 Z tqbfjotld Trampoline (info1cup20_trampoline) C++14
100 / 100
481 ms 30144 KB
#include <bits/stdc++.h>
using namespace std;

vector<pair<int,int> > items;
int decomp[200005][20];

int main(){
    int R,C,n;
    scanf("%d%d%d",&R,&C,&n);
    for (int x = 0; x<n; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        items.push_back({a,b});
    }
    sort(items.begin(),items.end());
    for (int x = 0; x<n; x++){
        int num = lower_bound(items.begin(),items.end(),make_pair(items[x].first+1,items[x].second))-items.begin();
        if (num==n) decomp[x][0] = n;
        else if (items[num].first!=items[x].first+1){
            decomp[x][0] = n;
        }
        else{
            decomp[x][0] = num;
        }
    }
    decomp[n][0] = n;
    for (int x = 1; x<20; x++){
        for (int y = 0; y<=n; y++){
            decomp[y][x] = decomp[decomp[y][x-1]][x-1];
        }
    }
    int q;
    scanf("%d",&q);
    for (int x = 0; x<q; x++){
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if (a>c || b>d){
            printf("No\n");
            continue;
        }
        if (a==c){
            printf("Yes\n");
            continue;
        }
        int num = lower_bound(items.begin(),items.end(),make_pair(a,b))-items.begin();
        if (items[num].first!=a){
            printf("No\n");
            continue;
        }
        int diff = c-a-1;
        for (int x = 0; x<20; x++){
            if (diff&(1<<x)){
                num = decomp[num][x];
            }
        }
        if (num==n){
            printf("No\n");
            continue;
        }
        if (items[num].second>d){
            printf("No\n");
            continue;
        }
        printf("Yes\n");

    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d%d",&R,&C,&n);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
trampoline.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d%d",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
trampoline.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
trampoline.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d%d%d%d",&a,&b,&c,&d);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1228 KB 200 token(s): yes count is 21, no count is 179
2 Correct 5 ms 1356 KB 200 token(s): yes count is 70, no count is 130
3 Correct 4 ms 972 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 19376 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 128 ms 19496 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 123 ms 19112 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 128 ms 19520 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 259 ms 30144 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 255 ms 29968 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 264 ms 29920 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 263 ms 29960 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 287 ms 30000 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 282 ms 29888 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1100 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 1100 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 6 ms 1112 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 6 ms 1100 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 7 ms 1100 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 7 ms 1116 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 407 ms 29924 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 376 ms 30000 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 277 ms 30020 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 420 ms 29928 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 365 ms 29920 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 290 ms 30128 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 333 ms 30120 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 330 ms 30012 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 449 ms 29924 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 481 ms 29956 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 475 ms 29932 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 281 ms 30076 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 268 ms 30056 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 335 ms 30020 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 281 ms 30080 KB 200000 token(s): yes count is 129674, no count is 70326