제출 #1170366

#제출 시각아이디문제언어결과실행 시간메모리
1170366sunboiWall (IOI14_wall)C++17
100 / 100
860 ms159516 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 1000; vector<int> a(N); vector<pair<long long, long long>> t(4 * N); void push(int v, int vl, int vr){ if (vr != vl){ t[2 * v].first = min(max(t[2 * v].first, t[v].first), t[v].second); t[2 * v].second = max(min(t[2 * v].second, t[v].second), t[v].first); t[2 * v + 1].first = min(max(t[2 * v + 1].first, t[v].first), t[v].second); t[2 * v + 1].second = max(min(t[2 * v + 1].second, t[v].second), t[v].first); t[v] = {0, 1e9}; } } void update(int v, int vl, int vr, int l, int r, long long x, int tt){ if (vl > r || vr < l) return; if (vl >= l && vr <= r){ if (tt == 1){ t[v] = {max(t[v].first, x), max(t[v].second, x)}; }else{ t[v] = {min(t[v].first, x), min(t[v].second, x)}; } return; } push(v, vl ,vr); int vm = (vl + vr) / 2; update(2 * v, vl, vm, l, r, x, tt); update(2 * v + 1, vm + 1, vr, l, r, x, tt); } int get(int v, int vl, int vr, int x){ if (vl > x || vr < x) return -1; if (vr == x && x == vl){ return t[v].first; } push(v, vl ,vr); int vm = (vl + vr) / 2; return max(get(2 * v, vl, vm, x), get(2 * v + 1, vm + 1, vr, x)); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ for (int i = 0; i < k; i++){ update(1, 0, n - 1, left[i], right[i], height[i], op[i]); } for (int i = 0; i < n; i++){ finalHeight[i] = get(1, 0, n - 1, i); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...