# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
526214 | 2022-02-14T00:51:53 Z | Lam_lai_cuoc_doi | Trampoline (info1cup20_trampoline) | C++17 | 408 ms | 52508 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; template <class T> void read(T &x) { x = 0; register int c; while ((c = getchar()) && (c > '9' || c < '0')) ; for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0'; } constexpr bool typetest = 0; constexpr int N = 2e5 + 5; int n, r, c, q; int ranks[N], par[N][18]; pair<int, int> a[N]; vector<int> adj[N]; void Read() { cin >> r >> c >> n; for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second; cin >> q; } void dfs(int v) { for (int i = 1; i < 18; ++i) par[v][i] = par[par[v][i - 1]][i - 1]; for (int i : adj[v]) if (i != par[v][0]) { par[i][0] = v; ranks[i] = ranks[v] + 1; dfs(i); } } void Solve() { sort(a + 1, a + n + 1); for (int i = 1; i <= n; ++i) { int j = lower_bound(a + 1, a + n + 1, make_pair(a[i].first + 1, a[i].second)) - a; if (j > n || a[j].first != a[i].first + 1) adj[0].emplace_back(i); else adj[j].emplace_back(i); } dfs(0); while (q--) { pair<int, int> start, goal; cin >> start.first >> start.second >> goal.first >> goal.second; if (start.first > goal.first || start.second > goal.second) { cout << "No\n"; continue; } if (start.first == goal.first) { cout << "Yes\n"; continue; } int j = lower_bound(a + 1, a + n + 1, start) - a; if (j > n || a[j].first != start.first || ranks[j] < goal.first - start.first) { cout << "No\n"; continue; } int u = ranks[j] - (goal.first - start.first) + 1, v = j; for (int i = 17; ~i; --i) if (ranks[par[v][i]] >= u) v = par[v][i]; if (a[v].second > goal.second) cout << "No\n"; else cout << "Yes\n"; } } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("tests.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } int t(1); if (typetest) cin >> t; for (int _ = 1; _ <= t; ++_) { // cout << "Case " << _ << ": "; Read(); Solve(); } cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; } /* */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5956 KB | 200 token(s): yes count is 21, no count is 179 |
2 | Correct | 6 ms | 6092 KB | 200 token(s): yes count is 70, no count is 130 |
3 | Correct | 6 ms | 5688 KB | 197 token(s): yes count is 25, no count is 172 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 95 ms | 26532 KB | 4000 token(s): yes count is 99, no count is 3901 |
2 | Correct | 101 ms | 26528 KB | 4000 token(s): yes count is 91, no count is 3909 |
3 | Correct | 98 ms | 28320 KB | 4000 token(s): yes count is 4000, no count is 0 |
4 | Correct | 97 ms | 26648 KB | 4000 token(s): yes count is 1991, no count is 2009 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 228 ms | 35240 KB | 200000 token(s): yes count is 110486, no count is 89514 |
2 | Correct | 228 ms | 36872 KB | 200000 token(s): yes count is 114664, no count is 85336 |
3 | Correct | 249 ms | 36956 KB | 200000 token(s): yes count is 86232, no count is 113768 |
4 | Correct | 268 ms | 37820 KB | 200000 token(s): yes count is 94603, no count is 105397 |
5 | Correct | 300 ms | 37820 KB | 200000 token(s): yes count is 94148, no count is 105852 |
6 | Correct | 275 ms | 41332 KB | 200000 token(s): yes count is 97163, no count is 102837 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 5836 KB | 5000 token(s): yes count is 3238, no count is 1762 |
2 | Correct | 9 ms | 5824 KB | 5000 token(s): yes count is 3837, no count is 1163 |
3 | Correct | 9 ms | 5800 KB | 5000 token(s): yes count is 4104, no count is 896 |
4 | Correct | 8 ms | 5836 KB | 5000 token(s): yes count is 3934, no count is 1066 |
5 | Correct | 9 ms | 5936 KB | 5000 token(s): yes count is 3384, no count is 1616 |
6 | Correct | 7 ms | 5708 KB | 5000 token(s): yes count is 3390, no count is 1610 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 337 ms | 43132 KB | 200000 token(s): yes count is 171404, no count is 28596 |
2 | Correct | 324 ms | 39056 KB | 200000 token(s): yes count is 161254, no count is 38746 |
3 | Correct | 295 ms | 37140 KB | 200000 token(s): yes count is 117455, no count is 82545 |
4 | Correct | 362 ms | 52508 KB | 200000 token(s): yes count is 182118, no count is 17882 |
5 | Correct | 278 ms | 41688 KB | 200000 token(s): yes count is 167565, no count is 32435 |
6 | Correct | 273 ms | 36984 KB | 200000 token(s): yes count is 156797, no count is 43203 |
7 | Correct | 277 ms | 37072 KB | 200000 token(s): yes count is 156797, no count is 43203 |
8 | Correct | 237 ms | 37148 KB | 200000 token(s): yes count is 122100, no count is 77900 |
9 | Correct | 360 ms | 41400 KB | 200000 token(s): yes count is 139670, no count is 60330 |
10 | Correct | 347 ms | 42128 KB | 200000 token(s): yes count is 165806, no count is 34194 |
11 | Correct | 408 ms | 46784 KB | 200000 token(s): yes count is 175646, no count is 24354 |
12 | Correct | 211 ms | 35048 KB | 200000 token(s): yes count is 134695, no count is 65305 |
13 | Correct | 232 ms | 35252 KB | 200000 token(s): yes count is 126733, no count is 73267 |
14 | Correct | 275 ms | 37928 KB | 200000 token(s): yes count is 155290, no count is 44710 |
15 | Correct | 233 ms | 37168 KB | 200000 token(s): yes count is 129674, no count is 70326 |