이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define f first
#define s second
pii tree[8000010]; const int INF = 2e9;
bool ckmin(int& A, int B) { return (B < A) ? A = B, true : false; }
bool ckmax(int& A, int B) { return (B > A) ? A = B, true : false; }
void pushdown(int x, int l, int r) {
for (int CHILD = 2 * x; CHILD <= 2 * x + 1; CHILD++) {
ckmax(tree[CHILD].s, tree[x].s); ckmax(tree[CHILD].f, tree[CHILD].s);
ckmin(tree[CHILD].f, tree[x].f); ckmin(tree[CHILD].s, tree[CHILD].f);
}
}
void update(int x, int l, int r, int tl, int tr, int T, int H) { int mid = (l + r) / 2;
if (l > tr || r < tl) return ; if (tl <= l && r <= tr) {
if (T == 1) { ckmax(tree[x].s, H); ckmax(tree[x].f, tree[x].s); return ; }
if (T == 2) { ckmin(tree[x].f, H); ckmin(tree[x].s, tree[x].f); return ; }
}
pushdown(x, l, r); update(2 * x, l, mid, tl, tr, T, H); update(2 * x + 1, mid + 1, r, tl, tr, T, H);
}
void genAns(int x, int l, int r, int finalHeight[]) { int mid = (l + r) / 2;
if (l == r) { finalHeight[l - 1] = tree[x].s; return ; }
pushdown(x, l, r); genAns(2 * x, l, mid, finalHeight); genAns(2 * x + 1, mid + 1, r, finalHeight);
}
void buildWall(int N, int K, int op[], int left[], int right[], int height[], int finalHeight[]) {
for (int i = 1; i <= 4 * N; i++) { tree[i].f = INF; tree[i].s = 0; }
for (int i = 0; i < K; i++) update(1, 1, N, left[i] + 1, right[i] + 1, op[i], height[i]);
genAns(1, 1, N, finalHeight);
}
컴파일 시 표준 에러 (stderr) 메시지
wall.cpp: In function 'void update(int, int, int, int, int, int, int)':
wall.cpp:23:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
23 | if (l > tr || r < tl) return ; if (tl <= l && r <= tr) {
| ^~
wall.cpp:23:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
23 | if (l > tr || r < tl) return ; if (tl <= l && r <= tr) {
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |