Submission #369984

# Submission time Handle Problem Language Result Execution time Memory
369984 2021-02-22T20:37:34 Z A_D Trampoline (info1cup20_trampoline) C++14
89 / 100
790 ms 82760 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();
        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);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 3940 KB 200 token(s): yes count is 21, no count is 179
2 Correct 13 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
# Verdict Execution time Memory Grader output
1 Correct 434 ms 81864 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 416 ms 81864 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 456 ms 81864 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 435 ms 81880 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Incorrect 633 ms 82600 KB expected NO, found YES [5147th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 788 ms 82636 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 754 ms 82760 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 636 ms 82504 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 776 ms 82504 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 727 ms 82504 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 640 ms 82636 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 663 ms 82632 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 669 ms 82516 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 743 ms 82504 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 770 ms 82564 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 790 ms 82636 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 615 ms 82504 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 625 ms 82664 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 697 ms 82616 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 616 ms 82632 KB 200000 token(s): yes count is 129674, no count is 70326