답안 #792345

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
792345 2023-07-25T02:02:49 Z Cookie Trampoline (info1cup20_trampoline) C++14
100 / 100
1110 ms 81560 KB
#include<bits/stdc++.h>
#include<fstream>
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
//ifstream fin("FEEDING.INP");
//ofstream fout("FEEDING.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ll mxn = 3e5 + 5, base = 972663749;
const ll mod = 911382323, mxv = 1e9 + 1, inf = 2e9;
int n, t, r, c;
map<int, set<int>>point;
map<pair<int, int>, int>id;
map<int, pair<int, int>>toid;
int mark = 0;
int up[mxn + 1][18], a[mxn + 1], b[mxn + 1];
int x1, y11, x2, y2; 
void solve(){
    auto st = point[x1].lower_bound(y11);
    if(st == point[x1].end()){
        cout << "No" << "\n";
        return;
    }
    int stid = id[make_pair(x1, *st)];
    int k = x2 - x1 - 1;
    for(int i = 0; i < 18; i++){
        if(k & (1 << i)){
            stid = up[stid][i];
        }
    }
    if(stid == 0){
        cout << "No" << "\n";
        return;
    } 
    auto [enx, eny] = toid[stid];
    assert(enx == x2 - 1);
    cout << ((eny <= y2) ? "Yes" : "No") << "\n";
}
signed main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    cin >> r >> c >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
        point[a[i]].insert(b[i]);
        id[{a[i], b[i]}] = ++mark;
        toid[mark] = make_pair(a[i], b[i]);
    }
    for(auto i: point){
        set<int>cand = i.second;
        for(auto j: cand){
            auto it = point[i.fi + 1].lower_bound(j);
            if(it != point[i.fi + 1].end()){
                up[id[make_pair(i.fi, j)]][0] = id[make_pair(i.fi + 1, *it)];
            }
        }
    }
    for(int i = 1; i < 18; i++){
        for(int j = 1; j <= n; j++){
            up[j][i] = up[up[j][i - 1]][i - 1];
        }
    }
    cin >> t;
    while(t--){
        cin >> x1 >> y11 >> x2 >> y2;
        if(x1 > x2 || y11 > y2){
            cout << "No" << "\n";
        }else if(x1 == x2){
            cout << "Yes" << "\n";
        }else{
            solve();
        }
    }
    return(0);
}

Compilation message

trampoline.cpp: In function 'void solve()':
trampoline.cpp:46:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   46 |     auto [enx, eny] = toid[stid];
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2516 KB 200 token(s): yes count is 21, no count is 179
2 Correct 10 ms 2904 KB 200 token(s): yes count is 70, no count is 130
3 Correct 7 ms 2132 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 52440 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 396 ms 52528 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 420 ms 52044 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 415 ms 52492 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 678 ms 73388 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 733 ms 69344 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 665 ms 63844 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 779 ms 63080 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 827 ms 62988 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 913 ms 68988 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1940 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 8 ms 1936 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 11 ms 2844 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 8 ms 2004 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 9 ms 2008 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 8 ms 2224 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 1037 ms 70256 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 876 ms 64724 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 713 ms 63732 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1110 ms 81560 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 893 ms 78932 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 789 ms 69280 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 787 ms 69328 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 713 ms 65428 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 927 ms 69012 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1047 ms 69052 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1093 ms 75404 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 620 ms 74656 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 660 ms 73804 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 807 ms 63068 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 660 ms 69408 KB 200000 token(s): yes count is 129674, no count is 70326