답안 #369988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369988 2021-02-22T20:46:39 Z A_D Trampoline (info1cup20_trampoline) C++14
100 / 100
813 ms 94388 KB
#include <bits/stdc++.h>
#define int long long
#define ii pair<int,int>
#define F first
#define S second
#define du long double
using namespace std;
const int N=4e5+1000;
const int l=20;
int nxt[N][l];
vector<ii> vec;
set<ii> st;
main()
{
    int r,c,n;
    cin>>r>>c>>n;
    for(int i=1;i<=n;i++){
        int a,b;
        scanf("%lld",&a);
        scanf("%lld",&b);
        vec.push_back({a,b});
        vec.push_back({a+1,b});
        st.insert({a,b});
    }
    sort(vec.begin(),vec.end());
    int sz=vec.size();
    for(int i=0;i<l;i++)nxt[sz][i]=sz;
    int nx=sz;
    for(int i=sz-1;i>=0;i--){
        int a=vec[i].F;
        int b=vec[i].S;
        if(i==sz-1||vec[i].F!=vec[i+1].F){
            nx=sz;
        }
        if(st.find({a,b})!=st.end())nx=lower_bound(vec.begin(),vec.end(),make_pair(a+1,b))-vec.begin();
        nxt[i][0]=nx;
    }
    for(int j=1;j<l;j++){
        for(int i=0;i<sz;i++){
            nxt[i][j]=nxt[nxt[i][j-1]][j-1];
        }
    }
    vec.push_back({1e10,1e10});
    int t;
    cin>>t;
    while(t--){
        int x1,x2,y1,y2;
        scanf("%lld",&x1);
        scanf("%lld",&y1);
        scanf("%lld",&x2);
        scanf("%lld",&y2);
        if(y2<y1||x2<x1){
            printf("No\n");
            continue;
        }
        if(x1==x2){
            printf("Yes\n");
            continue;
        }
        int i=lower_bound(vec.begin(),vec.end(),make_pair(x1,y1))-vec.begin();
        if(i==sz||vec[i].F!=x1){
            printf("No\n");
            continue;
        }
        for(int j=l-1;j>=0;j--){
            if(((x2-x1)&(1<<j))){
               if(i != sz) i = nxt[i][j];
            }
        }
        if(vec[i].S<=y2){
            printf("Yes\n");
            continue;
        }
        printf("No\n");
    }
}

Compilation message

trampoline.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      |      ^
trampoline.cpp: In function 'int main()':
trampoline.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         scanf("%lld",&a);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |         scanf("%lld",&b);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |         scanf("%lld",&x1);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   49 |         scanf("%lld",&y1);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   50 |         scanf("%lld",&x2);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |         scanf("%lld",&y2);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 3940 KB 200 token(s): yes count is 21, no count is 179
2 Correct 15 ms 4452 KB 200 token(s): yes count is 70, no count is 130
3 Correct 9 ms 3176 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 444 ms 82036 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 423 ms 81736 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 436 ms 82040 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 454 ms 81736 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 636 ms 82512 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 639 ms 94160 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 676 ms 94292 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 661 ms 94300 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 665 ms 94388 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 692 ms 94152 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2408 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 10 ms 2408 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 10 ms 2408 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 10 ms 2408 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 11 ms 2408 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 10 ms 2408 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 741 ms 82632 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 789 ms 82632 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 680 ms 82504 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 791 ms 82664 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 718 ms 82504 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 695 ms 82504 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 693 ms 82504 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 628 ms 82644 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 766 ms 82580 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 760 ms 82504 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 813 ms 82492 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 623 ms 82632 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 608 ms 82588 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 716 ms 82632 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 643 ms 82504 KB 200000 token(s): yes count is 129674, no count is 70326