제출 #725562

#제출 시각아이디문제언어결과실행 시간메모리
725562allin27x벽 (IOI14_wall)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; struct SGT{ int op; vector<int> t; int n; SGT(int sz, int op1){ n= sz; op = op1; t.resize(2*n, -1); } void apply(int p, int x){ if (t[p]==-1) {t[p] = x; return;} t[p] = abs(max(op*t[p], op*x)); } void update(int l, int r, int x){ for (l+=n, r+=n+1; l<r; l>>=1, r>>=1){ if (l&1) apply(l++, x); if (r&1) apply(--r, x); } } void push(){ for (int i=1; i<n; i++){ apply(i<<1, t[i]); apply(i<<1|1, t[i]); } } }; void brute_force(int n, int k, int op[], int l[],int r[],int h[], int ans[]){ for (int i=0; i<k; i++){ for(int j=l[i]; j<=r[i]; j++){ if (op[i] == 1) ans[j] = max(ans[j] , h[i]); if (op[i] == 2) ans[j] = min(ans[j] , h[i]); } } } void buildWall(int n, int k, int op[], int l[],int r[],int h[], int ans[]){ if (n<=10000) brute_force(n,k,op,l,r,h, ans); SGT add(n, 1); SGT rem(n, -1); for (int i=0; i<k; i++){ if (op[i]==1) add.update(l[i], r[i], h[i]); if (op[i]==2) rem.update(l[i], r[i], h[i]); } for (int i=0; i<n; i++) ans[i] = min(add.t[i+n], rem.t[i+n]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...