답안 #369944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369944 2021-02-22T19:27:14 Z A_D Trampoline (info1cup20_trampoline) C++14
0 / 100
458 ms 35704 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;
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});
    }
    sort(vec.begin(),vec.end());
    int sz=vec.size();
    for(int i=0;i<l;i++)nxt[sz][i]=sz;
    for(int i=0;i<sz;i++){
        int nx=lower_bound(vec.begin(),vec.end(),make_pair(vec[i].F+1,vec[i].S))-vec.begin();
        if(nx!=sz&&vec[nx].F!=vec[i].F+1){
            nx=sz;
        }
        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});
//    for(int i=0;i<vec.size();i++)cout<<i<<" "<<vec[i].F<<" "<<vec[i].S<<endl;
  //  cout<<endl;
    /*for(int i=0;i<sz;i++){
        for(int j=0;j<l;j++){
            cout<<nxt[i][j]<<" ";
        }
        cout<<endl;
    }*/
    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){
//            cout<<1;
            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)&(1<<j))){
               if(i != sz) i = nxt[i][j];
            }
        }
  //      cout<<i<<endl;
        int l=vec[i].S;
        if(x2-x1-1&&vec[i].S<=y2){
            printf("Yes\n");
            continue;
        }
        int r=nxt[i][0];
        r=vec[r].S;
    //    cout<<i<<endl;
        if(l<=y2&&y2<=r){
            printf("Yes\n");
            continue;
        }
        printf("No\n");
    }
}

Compilation message

trampoline.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main()
      |      ^
trampoline.cpp: In function 'int main()':
trampoline.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%lld",&a);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         scanf("%lld",&b);
      |         ~~~~~^~~~~~~~~~~
trampoline.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   50 |         scanf("%lld",&x1);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |         scanf("%lld",&y1);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |         scanf("%lld",&x2);
      |         ~~~~~^~~~~~~~~~~~
trampoline.cpp:53:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   53 |         scanf("%lld",&y2);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1896 KB expected YES, found NO [59th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 151 ms 34900 KB expected YES, found NO [1987th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 327 ms 35540 KB expected YES, found NO [12th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1308 KB expected YES, found NO [71st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 458 ms 35704 KB expected YES, found NO [450th token]
2 Halted 0 ms 0 KB -