Submission #426950

# Submission time Handle Problem Language Result Execution time Memory
426950 2021-06-14T11:08:02 Z lyc Trampoline (info1cup20_trampoline) C++14
100 / 100
930 ms 40016 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef pair<int,int> ii;

const int mxN = 2e5+5;
const int lgN = 18;

int R, C, N, T, A[mxN], B[mxN];
map<int,vector<ii>> rows;
int pa[mxN][lgN];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin >> R >> C >> N;
    FOR(i,1,N){
        int a, b; cin >> a >> b; 
        A[i] = a, B[i] = b;
        rows[a].push_back(ii(b,i));
    }

    for (auto& [a, v] : rows) {
        sort(ALL(v));
        auto& p = rows[a-1];
        auto it = p.begin();
        for (auto& [b, i] : v) {
            while (it != p.end() && next(it) != p.end() && next(it)->first <= b) ++it;
            if (it != p.end() && it->first <= b) pa[i][0] = it->second;
            else pa[i][0] = 0;
            FOR(k,1,lgN-1) pa[i][k] = pa[pa[i][k-1]][k-1];
        }
    }

    cin >> T;
    FOR(i,1,T){
        int a, b, c, d; cin >> a >> b >> c >> d;

        bool ok = 1;
        if (a > c || b > d) ok = 0;
        else if (a < c) {
            auto it = lower_bound(ALL(rows[c-1]), ii(d+1,0));
            if (it == rows[c-1].begin()) ok = 0;
            else {
                auto u = (--it)->second;
                RFOR(k,lgN-1,0) if (pa[u][k] && A[pa[u][k]] >= a) {
                    u = pa[u][k];
                }
                if (A[u] != a || B[u] < b) ok = 0;
            }
        }

        cout << (ok ? "Yes" : "No") << '\n';
    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:29:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |     for (auto& [a, v] : rows) {
      |                ^
trampoline.cpp:33:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         for (auto& [b, i] : v) {
      |                    ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1100 KB 200 token(s): yes count is 21, no count is 179
2 Correct 6 ms 1368 KB 200 token(s): yes count is 70, no count is 130
3 Correct 4 ms 972 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 127 ms 19076 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 138 ms 20372 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 153 ms 19644 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 132 ms 20480 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 294 ms 18740 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 334 ms 19552 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 313 ms 19796 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 390 ms 20468 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 367 ms 20328 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 640 ms 26276 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 6 ms 716 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 7 ms 1100 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 10 ms 1868 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 7 ms 1100 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 8 ms 1228 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 8 ms 1100 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 670 ms 26496 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 564 ms 22836 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 317 ms 20420 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 930 ms 40016 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 575 ms 26936 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 358 ms 20312 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 317 ms 20296 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 328 ms 20132 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 606 ms 26624 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 706 ms 26948 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 923 ms 32676 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 278 ms 19820 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 284 ms 20224 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 411 ms 20692 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 302 ms 19728 KB 200000 token(s): yes count is 129674, no count is 70326