Submission #261581

#TimeUsernameProblemLanguageResultExecution timeMemory
261581HeheheWall (IOI14_wall)C++14
0 / 100
185 ms8256 KiB
#include<bits/stdc++.h> //:3 using namespace std; typedef long long ll; #define all(a) (a).begin(), (a).end() #define ff first #define ss second #define pb push_back #define mp make_pair #define sz(x) (int)((x).size()) //#define int long long #include "wall.h" const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const int inf = 2e9; const ll mod = 1e9 + 7; const int N = 2e6 + 11; const ll INF64 = 3e18 + 1; const double eps = 1e-14; const double PI = acos(-1); //ifstream in(".in"); //ofstream out(".out"); int mx[4*N], mn[4*N], ans[N]; void build(int v, int l, int r){ if(l == r){ mx[v] = 0; mn[v] = inf; return; } int mid = (l + r) >> 1; build(2*v, l, mid); build(2*v + 1, mid + 1, r); } void push(int v){ //left mx[2*v] = min(mx[2*v], mn[v]); mx[2*v] = max(mx[2*v], mx[v]); mn[2*v] = min(mn[2*v], mn[v]); mn[2*v] = max(mn[2*v], mx[v]); //right mx[2*v + 1] = min(mx[2*v + 1], mn[v]); mx[2*v + 1] = max(mx[2*v + 1], mx[v]); mn[2*v + 1] = min(mn[2*v + 1], mn[v]); mn[2*v + 1] = max(mn[2*v + 1], mx[v]); mx[v] = 0; mn[v] = inf; } void update(int v, int tl, int tr, int l, int r, int H, int type){ //if(tl > r || tr < l)return; push(v); if(l <= tl && tr <= r){ if(type == 1){ mx[v] = max(mx[v], H); mn[v] = max(mn[v], H); }else{ mx[v] = min(mx[v], H); mn[v] = min(mn[v], H); } return; } int mid = (tl + tr) >> 1; if(l <= mid)update(2*v, tl, mid, l, r, H, type); if(r > mid)update(2*v + 1, mid + 1, tr, l, r, H, type); } void WooHoo(int v, int l, int r){ if(l == r){ ans[l] = mx[v]; return; } push(v); int mid = (l + r) >> 1; WooHoo(2*v, l, mid); WooHoo(2*v + 1, mid + 1, r); } void buildWall (int n, int k, int op[], int left[], int right[], int h[], int finalHeight[]){ build(1, 1, n); for(int i = 0; i < k; i++){ update(1, 1, n, left[i] + 1, right[i] + 1, h[i], op[i]); } WooHoo(1, 1, n); for(int i = 0; i < n; i++)finalHeight[i] = ans[i + 1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...