제출 #1131925

#제출 시각아이디문제언어결과실행 시간메모리
1131925anngela벽 (IOI14_wall)C++20
컴파일 에러
0 ms0 KiB
#include <vector> #include <algorithm> using namespace std; #define ls (x << 1) #define rs ((x << 1) | 1) const int MAX_N = 2e6+7; const int INF = 2e9; int res[MAX_N]; class SegTree { public: SegTree(int n): n{n}, t{4 * n + 10}, U{4 * n + 10}, D{4 * n + 10} {} void Dec(int x, int h) { t[x] = min(t[x], h); U[x] = min(U[x], h); D[x] = min(D[x], h); } void Add(int x, int h) { t[x] = max(t[x], h); U[x] = max(U[x], h); D[x] = max(D[x], h); } void PushDown(int x) { if (U[x] != -INF) { Add(ls, U[x]); Add(rs, U[x]); } if (D[x] != INF) { Dec(ls, D[x]); Dec(rs, D[x]); } U[x] = -INF, D[x] = INF; } void Update(int x, int l, int r, int a, int b, int h, int type) { if (l > b || r < a) return; if (a <= l && r <= b) { if (type == 1) Add(x, h); else Dec(x, h); return; } if (l != r) PushDown(x); int m = (l + r) / 2; Update(ls, l, m, a, b, h, type); Update(rs, m + 1, r, a, b, h, type); } void Update(int a, int b, int h, int type) { Update(1, 0, n - 1, a, b, h, type); } void GetRez(int x, int l, int r) { if (l == r) { res[l] = t[x]; return; } if (l != r) PushDown(x); int m = (l + r) / 2; GetRez(ls, l, m); GetRez(rs, m + 1, r); } void GetRez() { GetRez(1, 0, n - 1); } private: int n; vector<int> t; vector<int> U, D; // astea doua sunt lazy-uri pt "t" }; SegTree t(n); void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { for (int i = 0; i < k; ++i) t.Update(left[i], right[i], height[i], op[i]); t.GetRez(); for (int i = 0; i < n; ++i) finalHeight[i] = res[i]; }

컴파일 시 표준 에러 (stderr) 메시지

wall.cpp:92:11: error: 'n' was not declared in this scope
   92 | SegTree t(n);
      |           ^