Submission #1296286

#TimeUsernameProblemLanguageResultExecution timeMemory
1296286paronmanukyanObstacles for a Llama (IOI25_obstacles)C++20
10 / 100
2097 ms38800 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uniq(x) x.resize(unique(all(x)) - x.begin()) #define sort_uniq(x) sort(all(x)), uniq(x) #define no_el(x, y) x.find(y) == x.end() #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define V vector #define pb push_back #define eb emplace_back #define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define INF INT32_MAX #define blt __builtin_popcount #define sz(x) int(x.size()) #define rep(a, b, c, d) for (int a = b; a <= c; a += d) #define repl(a, b, c, d) for (int a = b; a >= c; a -= d) #define ld long double const int N = 2e5 + 5; const int LG = 19; int n, m; V<int> t, h; int stmn[N][LG], stmx[N][LG], lg2[N]; void initialize(V<int> T, V<int> H) { n = sz(T); m = sz(H); t.resize(n + 1); h.resize(m + 1); rep(i, 1, n, 1) t[i] = T[i - 1]; rep(i, 1, m, 1) h[i] = H[i - 1]; rep(i, 1, m, 1) { stmn[i][0] = h[i]; stmx[i][0] = h[i]; } rep(j, 1, LG - 1, 1) { rep(i, 1, m, 1) { int nx = i + (1 << (j - 1)); if (nx <= m) { stmn[i][j] = min(stmn[i][j - 1], stmn[nx][j - 1]); stmx[i][j] = max(stmx[i][j - 1], stmx[nx][j - 1]); } else { stmn[i][j] = stmn[i][j - 1]; stmx[i][j] = stmx[i][j - 1]; } } } lg2[1] = 0; rep(i, 2, N - 1, 1) lg2[i] = lg2[i >> 1] + 1; } int min_rng(int l, int r) { int j = lg2[r - l + 1]; return min(stmn[l][j], stmn[r - (1 << j) + 1][j]); } int max_rng(int l, int r) { int j = lg2[r - l + 1]; return max(stmx[l][j], stmx[r - (1 << j) + 1][j]); } bool can_reach(int tl, int tr, int s, int d) { ++s; ++d; if (s > d) swap(s, d); int lb = s, rb = s; for (int i = 1; i <= n; i++) { int L = 1, R = lb - 1, bestL = lb; while (L <= R) { int md = (L + R) >> 1; if (md <= s && max_rng(md, s) < t[i]) { bestL = md; R = md - 1; } else { L = md + 1; } } lb = bestL; L = rb + 1; R = m; int bestR = rb; while (L <= R) { int md = (L + R) >> 1; if (md >= s && max_rng(s, md) < t[i]) { bestR = md; L = md + 1; } else { R = md - 1; } } rb = bestR; if (rb >= d) return true; if (i == n) return false; if (lb > rb) return false; if (t[i + 1] <= min_rng(lb, rb)) return false; } return false; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...