답안 #481781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481781 2021-10-21T22:41:48 Z Yazan_Alattar Trampoline (info1cup20_trampoline) C++14
0 / 100
329 ms 27512 KB
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <utility>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 200007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

set < pair < pair < int,int >, int > > s;
pair <int,int> a[M];
int r, c, n, nxt[M][22];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> r >> c >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i].F >> a[i].S;
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; ++i){
        while(s.size()){
            pair < pair <int,int>, int > p = *s.begin();
            if(p.F.F + 1 < a[i].F) s.erase(s.begin());
            else if(p.F.F == a[i].F - 1 && p.F.S <= a[i].S){
                nxt[p.S][0] = i;
                s.erase(s.begin());
            }
            else break;
        }
        s.insert({a[i], i});
    }
    for(int j = 1; j <= 20; ++j)
        for(int i = 1; i <= n; ++i)
            nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
    int q;
    cin >> q;
    while(q--){
        pair <int,int> st, en;
        cin >> st.F >> st.S >> en.F >> en.S;
        if(st.F == en.F){
             if(st.S <= en.S) cout << "Yes\n";
             else cout << "No\n";
             continue;
        }
        int x = lower_bound(a + 1, a + n + 1, st) - a;
        if(x > n){
            cout << "No\n";
            continue;
        }
        if(a[x].F > st.F){
            cout << "No\n";
            continue;
        }
        for(int i = 20; i >= 0; --i){
            if(nxt[x][i] == 0) continue;
            if(a[nxt[x][i]].F <= en.F) x = nxt[x][i];
        }
        if((a[x].F == en.F || a[x].F + 1 == en.F) && a[x].S <= en.S) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1100 KB expected YES, found NO [68th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 19052 KB expected YES, found NO [1822nd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 242 ms 27512 KB expected YES, found NO [4th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 844 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 329 ms 19744 KB expected YES, found NO [1st token]
2 Halted 0 ms 0 KB -