답안 #921052

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921052 2024-02-03T09:13:13 Z thelegendary08 Trampoline (info1cup20_trampoline) C++14
0 / 100
2000 ms 26748 KB
#include<bits/stdc++.h>
#define f0r(i,n) for(int i = 0;i<n;i++)
#define pb push_back
#define ll long long int
using namespace std;
const int mxn = 500005;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll r,c,n;
    cin>>r>>c>>n;
    vector<pair<ll,ll>>green;
    set<ll>m[n + 5];
    map<int,int> gett;
    int ii = 0;
    f0r(i,n){
        ll x,y;
        cin>>x>>y;
        if(gett.count(x) != 0)m[gett[x]].insert(y);
        else{
            m[ii].insert(y);
            gett[x] = ii;
            ii++;

        }
        green.pb({x,y});
    }
    /*
    map<pair<ll,ll>, pair<ll,ll>>nxt;
    for(pair<ll,ll> p : green){
        auto ptr = lower_bound(m[p.first + 1].begin(), m[p.first + 1].end(), p.second);
        if(ptr != m[p.first + 1].end())nxt[p] = {p.first + 1, *ptr};
        else nxt[p] = {p.first + 1, p.second};
    }
    */
    int t;
    cin>>t;
    while(t--){
        bool ans = 1;
        ll sx, sy, ex, ey;
        cin>>sx>>sy>>ex>>ey;
        //if(ex - sx == 1){
            if(gett.count(sx) == 0)cout<<"No"<<'\n';
            //else if(m[gett[sx]].size() == 0)cout<<"No"<<'\n';
            else{
                auto curptr = lower_bound(m[gett[sx]].begin(), m[gett[sx]].end(),sy);
                if(curptr == m[gett[sx]].end())cout<<"No"<<'\n';
                else{
                    if(*curptr<=ey)cout<<"Yes"<<'\n';
                    else cout<<"No"<<'\n';
                }
            }

        //}
        /*
        else{
            if(sx == ex)cout<<"Yes"<<'\n';
            else if(sx > ex || sy > ey)cout<<"No"<<'\n';
            else if(m.count(sx) == 0 || m.count(ex) == 0)cout<<"No"<<'\n';
            else{
                auto ptr1 = lower_bound(m[sx].begin(), m[sx].end(), sy);
                //auto ptr2 = upper_bound(m[ex].begin(), m[ex].end(), ey);
                if(ptr1 == m[sx].end()){

                    ans = 0;
                }
                */
                /*
                if(ptr2 == m[sy].begin()){
                    cout<<"No"<<'\n';
                    break;
                }
                ptr2--;
                */
                /*
                if(ans){
                    sy = *ptr1;
                    //ey = *ptr2;

                    pair<ll,ll> loc = {sx, sy};

                    while(loc.first <ex){
                        //cout<<loc.first<<' '<<loc.second<<'\n';
                        if(nxt.count(loc) == 0){
                            ans = 0;
                            break;
                        }

                        else{
                            if(loc.first == ex - 1)loc = {loc.first + 1, loc.second};
                            else loc = nxt[loc];
                        }

                    }
                    if(!ans)cout<<"No"<<'\n';
                    else if(loc.second <= ey)cout<<"Yes"<<'\n';
                    else cout<<"No"<<'\n';
                }
                else{
                    cout<<"No"<<'\n';
                }


            }
        }
        */


    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:40:14: warning: unused variable 'ans' [-Wunused-variable]
   40 |         bool ans = 1;
      |              ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1368 KB expected NO, found YES [2nd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 120 ms 22456 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2039 ms 22308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 860 KB expected NO, found YES [17th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 420 ms 26748 KB expected NO, found YES [23rd token]
2 Halted 0 ms 0 KB -