Submission #447810

#TimeUsernameProblemLanguageResultExecution timeMemory
447810hhhhauraWall (IOI14_wall)C++14
100 / 100
1158 ms68036 KiB
#include "wall.h" #include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma loop-opt(on) #define rep(i, a, b) for(int i = a; i <= b; i ++) #define rrep(i, a, b) for(int i = b; i >= a; i --) #define ceil(a, b) ((a + b - 1) / (b)) #define all(x) x.begin(), x.end() #define INF 1000000000 #define MOD 1000000007 #define eps (1e-9) using namespace std; #define lld long double #define pii pair<int, int> #define random mt19938 rnd(chrono::steady_clock::now().time_since_epoch().count()) #ifdef wiwihorz #define print(a...) cerr << "Line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a) void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;} void kout() { cerr << endl; } template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); } #else #define print(...) 0 #define vprint(...) 0 #endif int n; vector<int> mn, mx; void init_(int _n) { n = _n; mn.assign(2 * n + 1, INF); mx.assign(2 * n + 1, -INF); } int get(int L, int R) { L++, R++; return (L + R) | (L != R); } void push(int L, int R) { int nd = get(L, R), mid = (L + R) / 2; int l = get(L, mid), r = get(mid + 1, R); mx[l] = max(mx[l], mx[nd]); mx[r] = max(mx[r], mx[nd]); mn[l] = max(mn[l], mx[nd]); mn[r] = max(mn[r], mx[nd]); mn[l] = min(mn[l], mn[nd]); mn[r] = min(mn[r], mn[nd]); mn[nd] = INF, mx[nd] = -INF; } void down(int L, int R) { int nd = get(L, R), mid = (L + R) / 2; if(L == R) return; push(L, R); down(L, mid); down(mid + 1, R); } void modify(int L, int R, int l, int r, int op, int x) { int nd = get(L, R), mid = (L + R) / 2; if(l > R || r < L) return; if(L != R) push(L, R); if(l <= L && r >= R) { if(op == 2) mn[nd] = min(mn[nd], x); else mx[nd] = max(mx[nd], x), mn[nd] = max(mn[nd], x); } else { modify(L, mid, l, r, op, x); modify(mid + 1, R, l, r, op, x); } } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ init_(n); rep(i, 0, k - 1) modify(0, n - 1, left[i], right[i], op[i], height[i]); down(0, n - 1); rep(i, 0, n - 1) finalHeight[i] = min(max(0, mx[get(i, i)]), mn[get(i, i)]); return; }

Compilation message (stderr)

wall.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
wall.cpp: In function 'void down(int, int)':
wall.cpp:56:6: warning: unused variable 'nd' [-Wunused-variable]
   56 |  int nd = get(L, R), mid = (L + R) / 2;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...