답안 #369987

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369987 2021-02-22T20:44:27 Z A_D Trampoline (info1cup20_trampoline) C++14
0 / 100
642 ms 82468 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 Incorrect 11 ms 3940 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 445 ms 81736 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 580 ms 82376 KB expected YES, found NO [4th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 2408 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 642 ms 82468 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -