Submission #241281

#TimeUsernameProblemLanguageResultExecution timeMemory
241281abacabaWall (IOI14_wall)C++14
0 / 100
221 ms108024 KiB
#include <iostream> #include <string> #include <unordered_map> #include <unordered_set> #include "wall.h" #include <cstring> #include <chrono> #include <vector> #include <map> #include <random> #include <set> #include <algorithm> #include <math.h> #include <cstdio> #include <stdio.h> #include <queue> #include <bitset> #include <cstdlib> #include <deque> #include <cassert> #include <stack> using namespace std; #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define emb emplace_back #define ll long long #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define endl '\n' #define uset unordered_set #define umap unordered_map #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> inline T range(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } inline void setin(string s) { freopen(s.c_str(), "r", stdin); } inline void setout(string s) { freopen(s.c_str(), "w", stdout); } template <typename T> void Min(T &a, T b) { a = min(a, b); } template <typename T> void Max(T &a, T b) { a = max(a, b); } const int inf = 0x3f3f3f3f; const int mod = 998244353; const int N = 2e6 + 15; struct segment_tree { int mn[N << 2], mx[N << 2], add[N << 2]; segment_tree() { memset(mn, 0, sizeof(mx)); memset(mx, 0, sizeof(mn)); memset(add, -1, sizeof(add)); } inline void push(int v) { if(v < (N << 1) && add[v] != -1) { mn[v << 1] = mx[v << 1] = add[v]; mn[v << 1 | 1] = mx[v << 1 | 1] = add[v]; add[v << 1] = add[v << 1 | 1] = add[v]; add[v] = -1; } } void multiupdate(int v, int tl, int tr, int l, int r, int h, int type) { if(tl > r || tr < l || (type == 1 && mn[v] >= h) || (type == 2 && mx[v] <= h)) return; push(v); if(tl >= l && tr <= r && ((type == 1 && mx[v] <= h) || (type == 2 && mn[v] >= h))) mn[v] = mx[v] = add[v] = h; else if(tl != tr) { int mid = tl + tr >> 1; multiupdate(v << 1, tl, mid, l, r, h, type); multiupdate(v << 1 | 1, mid + 1, tr, l, r, h, type); mn[v] = min(mn[v << 1], mn[v << 1 | 1]); mx[v] = max(mx[v << 1], mx[v << 1 | 1]); } } void output(int v, int tl, int tr, int finalHeight[]) { if(tl == tr) finalHeight[tl] = mn[v]; else { push(v); int mid = tl + tr >> 1; output(v << 1, tl, mid, finalHeight); output(v << 1 | 1, mid + 1, tr, finalHeight); } } } t; void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ for(int i = 0; i < n; ++i) t.multiupdate(1, 0, n - 1, left[i], right[i], height[i], op[i]); t.output(1, 0, n - 1, finalHeight); }

Compilation message (stderr)

wall.cpp: In member function 'void segment_tree::multiupdate(int, int, int, int, int, int, int)':
wall.cpp:89:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid = tl + tr >> 1;
                       ~~~^~~~
wall.cpp: In member function 'void segment_tree::output(int, int, int, int*)':
wall.cpp:101:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid = tl + tr >> 1;
                       ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...