답안 #481786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481786 2021-10-21T23:03:45 Z Yazan_Alattar Trampoline (info1cup20_trampoline) C++14
100 / 100
385 ms 43480 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 || a[x].F != st.F){
            cout << "No\n";
            continue;
        }
        for(int i = 20; i >= 0; --i)
            if(nxt[x][i] && a[nxt[x][i]].F < en.F) x = nxt[x][i];
        if(en.F == a[x].F + 1 && a[x].S <= en.S){
            cout << "Yes\n";
            continue;
        }
        if(nxt[x][0]) x = nxt[x][0];
        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 Correct 4 ms 1100 KB 200 token(s): yes count is 21, no count is 179
2 Correct 4 ms 1228 KB 200 token(s): yes count is 70, no count is 130
3 Correct 3 ms 936 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 18992 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 108 ms 20948 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 103 ms 20556 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 116 ms 20944 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 244 ms 27604 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 268 ms 26000 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 245 ms 20456 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 292 ms 19748 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 262 ms 19800 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 342 ms 19772 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 844 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 6 ms 1100 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 5 ms 1100 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 5 ms 1228 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 6 ms 1100 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 1356 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 325 ms 19868 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 358 ms 31460 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 266 ms 31988 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 367 ms 31396 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 305 ms 37700 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 276 ms 37780 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 278 ms 37828 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 261 ms 33340 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 385 ms 31400 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 370 ms 31516 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 366 ms 31408 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 287 ms 43480 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 270 ms 39376 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 309 ms 31496 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 289 ms 35792 KB 200000 token(s): yes count is 129674, no count is 70326