Submission #685719

# Submission time Handle Problem Language Result Execution time Memory
685719 2023-01-24T22:05:15 Z divad Trampoline (info1cup20_trampoline) C++14
0 / 100
1238 ms 18676 KB
#include <iostream>
#include <vector>
#include <map>
#define pii pair<int, int>
using namespace std;
int r,c,n,T,x1,x2,y1,y2;
vector<pii> secv;
map<int, vector<int>> mp;

bool trecut(pii s, int x){
    return (s.first <= x || x <= s.second);
}

bool inclus(pii s, int x){
    return (s.first <= x && x <= s.second);
}

int next_pos(int row, int col){
    int st = 0, dr = mp[row].size()-1;
    int ans = -1;
    while(st <= dr){
        int mid = ((st+dr)>>1);
        if(mp[row][mid] >= col){
            ans = mid;
            dr = mid-1;
        }else{
            st = mid+1;
        }
    }
    if(ans != -1){
        return mp[row][ans];
    }
    return ans;
}

void solve(){
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1 > x2 || y1 > y2){
        cout << "No\n"; return ;
    }
    if(x1 == x2){
        cout << "Yes\n"; return ;
    }
    int st = 0, dr = secv.size()-1;
    int ans = -1;
    while(st <= dr){
        int mid = ((st+dr)>>1);
        if(trecut(secv[mid], x1)){
            ans = mid;
            dr = mid-1;
        }else{
            st = mid+1;
        }
    }
    if(ans == -1){
        cout << "No\n";
        return ;
    }
    if(!inclus(secv[ans], x2)){
        cout << "No\n"; return ;
    }
    bool ok = true;
    while(x1 < x2){
        y1 = next_pos(x1, y1);
        if(y1 == -1){
            ok = false;
            break;
        }
        x1++;
    }
    if(ok){
        ok = (y1 <= y2);
    }
    cout << (ok ? "Yes" : "No") << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> r >> c >> n;
    for(int i = 1; i <= n; i++){
        cin >> x1 >> y1;
        mp[x1].push_back(y1);
    }
    int ind = -1;
    for(auto [row, v]: mp){
        if(secv.size() == 0){
            secv.push_back({row, row+1});
            ind++;
        }else{
            if(row == secv[ind].second){
                secv[ind].second = row+1;
            }else{
                secv.push_back({row, row+1});
                ind++;
            }
        }
    }
    /*for(auto [st, dr]: secv){
        cout << st << ", " << dr << "\n";
    }*/
    cin >> T;
    while(T--){
        solve();
    }
    return 0;
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:87:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   87 |     for(auto [row, v]: mp){
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 3396 KB expected YES, found NO [3rd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 11176 KB expected YES, found NO [4th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 592 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1238 ms 18676 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -