Submission #50261

#TimeUsernameProblemLanguageResultExecution timeMemory
50261Just_Solve_The_ProblemWall (IOI14_wall)C++11
100 / 100
1665 ms268824 KiB
#include <bits/stdc++.h> #include "wall.h" #define pb push_back #define eb emplace_back #define ll long long #define pii pair < int, int > #define fr first #define sc second #define mk make_pair #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() #define ok puts("ok"); #define whatis(x) cerr << #x << " = " << x << endl; #define pause system("pause"); #define random (rand() ^ (rand() << 15)) using namespace std; const int N = (int)2e6 + 7; const int inf = (int)1e9 + 7; int n, c; struct T { int mn, mx; T() { mn = 1e5; mx = 0; } }; T tree[N * 4]; int* a; void push(int v, int op, int val) { if (op == 1) { tree[v].mn = max(tree[v].mn, val); tree[v].mx = max(tree[v].mx, val); } else if (op == 2) { tree[v].mn = min(tree[v].mn, val); tree[v].mx = min(tree[v].mx, val); } } void upd(int v, int tl, int tr, int l, int r, int op, int val) { if (tl > r || tr < l) return ; if (l <= tl && tr <= r) { push(v, op, val); a[l] = tree[v].mx; return ; } int mid = (tl + tr) >> 1; push(v + v, 1, tree[v].mx); push(v + v + 1, 1, tree[v].mx); push(v + v, 2, tree[v].mn); push(v + v + 1, 2, tree[v].mn); tree[v] = T(); upd(v + v, tl, mid, l, r, op, val); upd(v + v + 1, mid + 1, tr, l, r, op, val); } void buildWall(int nn, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ n = nn; a = finalHeight; for (int i = 0; i < k; i++) { upd(1, 0, n - 1, left[i], right[i], op[i], height[i]); } for (int i = 0; i < n; i++) { upd(1, 0, n - 1, i, i, 1, 0); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...