제출 #442476

#제출 시각아이디문제언어결과실행 시간메모리
442476SirCovidThe19th벽 (IOI14_wall)C++14
0 / 100
190 ms13852 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second const int mx = (1<<22); int N; pair<int, int> seg[mx*2]; // f - lowest, s - highest void comb(int i, int l, int h){ seg[i].f = (l != 1e6) ? min(seg[i].f, l) : max(seg[i].f, h); seg[i].s = (h != 0) ? max(seg[i].s, h) : min(seg[i].s, l); } void push(int i){ comb(i*2, seg[i].f, seg[i].s), comb(i*2+1, seg[i].f, seg[i].s); seg[i] = {1e6, 0}; } void upd(int x, int y, int op, int v, int l = 0, int r = N-1, int i = 1){ if (l > y or r < x) return; if (l >= x and r <= y){ comb(i, ((op == 2) ? v : 1e6), ((op == 1) ? v : 0)); return; } push(i); int m = (l+r)/2; upd(x, y, op, v, l, m, i*2); upd(x, y, op, v, m+1, r, i*2+1); } void solve(int* res, int l = 0, int r = N-1, int i = 1){ if (l == r){ res[l] = seg[i].s; return; } push(i); int m = (l+r)/2; solve(res, l, m, i*2); solve(res, m+1, r, i*2+1); } void buildWall(int n, int k, int op[], int l[], int r[], int h[], int res[]){ N = n; for (int i = 0; i < k; i++) upd(l[i], r[i], op[i], h[i]); solve(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...