답안 #914756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914756 2024-01-22T16:06:09 Z NValchanov Trampoline (info1cup20_trampoline) C++17
54 / 100
152 ms 16100 KB
#include<bits/stdc++.h>

#define endl '\n'
#define x first
#define y second
using namespace std;

typedef long long ll;

const ll MAXN=2e5+10;
const ll MAXR=1e9+10;
const ll MAXC=1e9+10;
const ll MAXT=2e5+10;

ll r,c,n,t;
bool a[3000][3000];
vector<pair<ll,ll>>v;

bool check(ll x1,ll y1,ll x2,ll y2)
{
    return x1<=x2&&y1<=y2;
}

void query(ll x1,ll y1,ll x2,ll y2)
{
    if(!check(x1,y1,x2,y2))
    {
        cout<<"No"<<endl;
        return;
    }
    ll x=x1,y=y1;
    while(x<=r&&y<=c)
    {
        if(x==x2&&y==y2)
        {
            cout<<"Yes"<<endl;
            return;
        }
        if(a[x][y]&&x<x2)
            x++;
        else
            y++;
    }
    cout<<"No"<<endl;
}

bool check_k(ll k,ll x1,ll y1)
{
    pair<ll,ll>cur=v[k];
    return cur.x>x1 || (cur.x==x1&&cur.y>=y1);
}

void special_query(ll x1,ll y1,ll x2,ll y2)
{
    if(!check(x1,y1,x2,y2))
    {
        cout<<"No"<<endl;
        return;
    }
    ll left=-1,right=v.size(),mid;
    while(right-left>1)
    {
        mid=left+(right-left)/2;
        if(check_k(mid,x1,y1))
            right=mid;
        else
            left=mid;
    }
    ///cout<<right<<endl;
    if(right<v.size()&&v[right].x+1==x2&&v[right].y<=y2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

void read()
{
    cin>>r>>c>>n;
    for(ll i=1;i<=n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(r<=2500&&c<=2500)
            a[x][y]=true;
        v.push_back(make_pair(x,y));
    }
    cin>>t;
    sort(v.begin(),v.end());
    for(ll i=1;i<=t;i++)
    {
        ll x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if(x1+1==x2&&r>2500&&c>2500)
            special_query(x1,y1,x2,y2);
        else
            query(x1,y1,x2,y2);
    }
}

int main()
{
    #ifdef ONLINE_JUDGE
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

    read();

	return 0;
}
/*
4 5 2
2 2
3 4
4
2 1 4 5
1 2 1 4
2 3 3 4
2 1 3 4
*/

Compilation message

trampoline.cpp: In function 'void special_query(ll, ll, ll, ll)':
trampoline.cpp:70:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     if(right<v.size()&&v[right].x+1==x2&&v[right].y<=y2)
      |        ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2908 KB 200 token(s): yes count is 21, no count is 179
2 Correct 3 ms 2908 KB 200 token(s): yes count is 70, no count is 130
3 Correct 2 ms 2908 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 14004 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 56 ms 14032 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 44 ms 8144 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 60 ms 14036 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 4816 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 138 ms 16100 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 140 ms 15808 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 152 ms 16040 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 144 ms 16064 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 146 ms 15804 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 50 ms 7120 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -