Submission #951570

#TimeUsernameProblemLanguageResultExecution timeMemory
951570EsgeerWall (IOI14_wall)C++17
24 / 100
647 ms29708 KiB
#ifndef Local #pragma GCC optimize("O3,unroll-loops") #endif #include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <unistd.h> using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //#define int long long #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vpi vector<pii> #define vvpi vector<vpi> #define vb vector<bool> #define vvb vector<vb> #define endl '\n' #define sp << " " << #define F(i, s, n) for(int i = s; i < n; i++) #define pb push_back #define fi first #define se second int mod = 998244353; int inf = 1e9; const int N = 5e5+5; #include "wall.h" struct Node { int mn, mx; }; struct Update { int mn, mx, last; }; Node merge(Node a, Node b) { return {-inf, inf}; } Update merge(Update a, Update b) { Update c = {max(a.mn, b.mn), min(a.mx, b.mx), b.last}; if(b.last == 2) c.last = a.last; if(c.mn > c.mx) { if(c.last) c.mn = c.mx; else c.mx = c.mn; } return c; } Node merge(Node a, Update b) { Node c = {max(a.mn, b.mn), min(a.mx, b.mx)}; if(c.mn > c.mx) { if(b.last) c.mn = c.mx; else c.mx = c.mn; } return c; } Node t[4*N]; Update lazy[4*N]; int a[N]; void push(int node, int l, int r) { t[node] = merge(t[node], lazy[node]); if(l != r) { lazy[node*2+1] = merge(lazy[node*2+1], lazy[node]); lazy[node*2+2] = merge(lazy[node*2+2], lazy[node]); } lazy[node] = {-inf, inf, 2}; } void build(int node, int l, int r) { lazy[node] = {-inf, inf, 2}; if(l == r) { t[node] = {-inf, inf}; return; } int mid = (l + r) >> 1; build(node*2+1, l, mid); build(node*2+2, mid+1, r); } void update(int node, int l, int r, int L, int R, int a, int b) { push(node, l, r); if(l > R || r < L) return; if(l >= L && r <= R) { if(b == 0) lazy[node] = {a, inf, 0}; else lazy[node] = {-inf, a, 1}; push(node, l, r); return; } int mid = (l + r) >> 1; update(node*2+1, l, mid, L, R, a, b); update(node*2+2, mid+1, r, L, R, a, b); } Node query(int node, int l, int r, int idx) { push(node, l, r); if(l > idx || r < idx) return {-inf, inf}; if(l == r) { return t[node]; } int mid = (l + r) >> 1; if(idx <= mid) return query(node*2+1, l, mid, idx); else return query(node*2+2, mid+1, r, idx); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { build(0, 0, n-1); F(i, 0, k) { if(op[i] == 1) { update(0, 0, n-1, left[i], right[i], height[i], 0); } else { update(0, 0, n-1, left[i], right[i], height[i], 1); } } F(i, 0, n) { Node q = query(0, 0, n-1, i); finalHeight[i] = min(max(q.mn, 0), q.mx); } } /* void solve() { int op[] = {1, 2, 2, 1, 1, 2}; int left[] = {1, 4, 3, 0, 2, 6}; int right[] = {8, 9, 6, 5, 2, 7}; int heights[] = {4, 1, 5, 3, 5, 0}; int res[6]; buildWall(10, 6, op, left, right, heights, res); F(i, 0, 10) cout << res[i] << " "; cout << endl; } void setIO() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef Local freopen("local.in", "r", stdin); freopen("local.out", "w", stdout); #else // freopen("poetry.in","r",stdin); // freopen("poetry.out","w",stdout); #endif } signed main() { setIO(); int t = 1; //cin >> t; while(t--) solve(); }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...