Submission #920981

# Submission time Handle Problem Language Result Execution time Memory
920981 2024-02-03T08:38:11 Z thelegendary08 Trampoline (info1cup20_trampoline) C++14
0 / 100
2000 ms 36196 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(){
    ll r,c,n;
    cin>>r>>c>>n;
    vector<pair<ll,ll>>green;
    map<ll, set<ll>>m;
    f0r(i,n){
        ll x,y;
        cin>>x>>y;
        m[x].insert(y);
        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--){
        ll sx, sy, ex, ey;
        cin>>sx>>sy>>ex>>ey;
        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()){
                cout<<"No"<<'\n';

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

            pair<ll,ll> loc = {sx, sy};
            bool ans = 1;
            ll se = 2e9;
            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';

        }

    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:52:16: warning: unused variable 'se' [-Wunused-variable]
   52 |             ll se = 2e9;
      |                ^~
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1496 KB 200 token(s): yes count is 21, no count is 179
2 Correct 24 ms 1752 KB 200 token(s): yes count is 70, no count is 130
3 Incorrect 11 ms 1372 KB Answer contains longer sequence [length = 197], but output contains 52 elements
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1281 ms 29200 KB 4000 token(s): yes count is 99, no count is 3901
2 Incorrect 1166 ms 28828 KB Answer contains longer sequence [length = 4000], but output contains 774 elements
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2064 ms 12952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 1296 KB expected NO, found YES [16th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2100 ms 36196 KB Time limit exceeded
2 Halted 0 ms 0 KB -