Submission #823978

#TimeUsernameProblemLanguageResultExecution timeMemory
823978annabeth9680Wall (IOI14_wall)C++17
100 / 100
448 ms69544 KiB
#include <bits/stdc++.h> using namespace std; #define MP make_pair #define FF first #define SS second const int inf = 2000000011; const pair<int,int> def = MP(-inf, inf); int N, Q; pair<int,int> T[8000000]; void init(int t = 1, int tl = 0, int tr = N - 1) { if (tl == 0 && tr == N - 1) T[t] = MP(0, 0); else T[t] = def; if (tl == tr) return; int tm = (tl + tr) >> 1; init(t << 1, tl, tm); init(t << 1 | 1, tm + 1, tr); } pair<int,int> push(pair<int,int> a, pair<int,int> b) { if (a.SS < b.FF) return MP(a.SS, a.SS); if (b.SS < a.FF) return MP(a.FF, a.FF); return MP(max(a.FF, b.FF), min(a.SS, b.SS)); } void pushdown(int t) { if (T[t] != def) { T[t << 1] = push(T[t], T[t << 1]); T[t << 1 | 1] = push(T[t], T[t << 1 | 1]); T[t] = def; } } void update(int l, int r, pair<int,int> v, int t = 1, int tl = 0, int tr = N - 1) { if (r < tl || tr < l) return; if (l <= tl && tr <= r) { T[t] = push(v, T[t]); return; } if (tl != tr) pushdown(t); int tm = (tl + tr) >> 1; update(l, r, v, t << 1, tl, tm); update(l, r, v, t << 1 | 1, tm + 1, tr); } void pushall(int* ans, int t = 1, int tl = 0, int tr = N - 1) { if (tl == tr) { ans[tl] = T[t].FF; return; } else pushdown(t); int tm = (tl + tr) >> 1; pushall(ans, t << 1, tl, tm); pushall(ans, t << 1 | 1, tm + 1, tr); } void buildWall(int n, int k, int* op, int* lb, int* rb, int* h, int* ans) { N = n, Q = k; init(); for (int q = 0; q < Q; q++) { pair<int,int> v = def; if (op[q] == 1) v.FF = h[q]; else if (op[q] == 2) v.SS = h[q]; update(lb[q], rb[q], v); } pushall(ans); } int n, q, op[500005], lb[500005], rb[500005], h[500005], ans[500005];
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...