제출 #1312914

#제출 시각아이디문제언어결과실행 시간메모리
1312914nikaa123벽 (IOI14_wall)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> #include "wall.h" using namespace std; const int N = 5e5+5; int t[4*N]; int lazy1[4*N]; int lazy2[4*N]; void applay(int node, int h, int op) { if (op == 1) { t[node] = max(t[node],h); lazy1[node] = h; lazy2[node] = -1; } else { t[node] = min(t[node],h); lazy2[node] = h; lazy1[node] = -1; } } void push(int node) { if (lazy1[node] != -1) { applay(node*2,lazy1[node],1); applay(node*2+1,lazy1[node],1); lazy1[node] = -1; } if (lazy2[node] != -1) { applay(node*2,lazy2[node],2); applay(node*2+1,lazy2[node],2); lazy2[node] = -1; } } void update(int node, int l, int r, int L, int R, int h, int op) { if (l > R || r < L) return; if (l >= L && r <= R) { applay(node,h,op); return; } push(node); int mid = (l+r)/2; update(node*2,l,mid,L,R,h,op); update(node*2+1,mid+1,r,L,R,h,op); } int getans(int node, int l, int r, int pos) { if (l == r) { return t[node]; } int mid = (l+r)/2; if (pos <= mid) { return getans(node*2,l,mid,pos); } else { return getans(node*2+1,mid+1,r,pos); } } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ for (int i = 1; i <= 4*n; i++) { lazy1[i] = lazy2[i] = -1; } for (int i = 1; i <= k; i++) { update(1,1,n,left[i]+1,right[i]+1,height[i],op[i]); } for (int i = 1; i <= n; i++) { finalHeight[i-1] = getans(1,1,n,i); } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...