F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

View Compilation Error

0_0_33137523_13441.cpp: In function 'void pushup(int)':
0_0_33137523_13441.cpp:21:242: error: expected '}' at end of input
 void pushup(int rt) { sum[rt] = sum[rt << 1] + sum[rt << 1 | 1]; mx[rt] = max(mx[rt << 1], mx[rt << 1 | 1]); if (mx[rt << 1] == mx[rt << 1 | 1]) { se[rt] = max(se[rt << 1], se[rt << 1 | 1]); num[rt] = num[rt << 1] + num[rt << 1 | 1]; } else { //这个地方需要特别注意!因为一个子树的次大值有可能比另一个子树的最大值还要大。所以总的次大值不一定是哪个,需要都比较一下。debug了很久很久。。。 se[rt] = max(se[rt<<1],se[rt<<1|1]); se[rt] = max(se[rt],min(mx[rt << 1], mx[rt << 1 | 1])); num[rt] = mx[rt << 1] > mx[rt << 1 | 1] ? num[rt << 1] : num[rt << 1 | 1]; } } void build(int rt, int l, int r) { if (l == r) { scanf("%lld", &sum[rt]); mx[rt] = sum[rt]; se[rt] = -1; num[rt] = 1; return; } build(lson); build(rson); pushup(rt); } void putTag(int rt, int x) { if (x >= mx[rt]) return; sum[rt] -= num[rt] * (mx[rt] - x); mx[rt] = x; } void pushdown(int rt) { putTag(rt << 1, mx[rt]); putTag(rt << 1 | 1, mx[rt]); } void change(int L, int R, int rt, int l, int r, int x) { if (x >= mx[rt]) return; if (L <= l && R >= r && se[rt] < x) { putTag(rt, x); return; } pushdown(rt); if (L <= (l + r) / 2) change(L, R, lson, x); if (R > (l + r) / 2) change(L, R, rson, x); pushup(rt); } int queryMax(int L, int R, int rt, int l, int r) { if (L <= l && R >= r) { return mx[rt]; } pushdown(rt); int ans = 0; if (L <= (l + r) / 2) ans = queryMax(L, R, lson); if (R > (l + r) / 2) ans = max(ans, queryMax(L, R, rson)); return ans; } ll querySum(int L, int R, int rt, int l, int r) { if (L <= l && R >= r) { return sum[rt]; } pushdown(rt); ll ans = 0; if (L <= (l + r) / 2) ans += querySum(L, R, lson); if (R > (l + r) / 2) ans += querySum(L, R, rson); return ans; } int main() { int T; scanf("%d", &T); while (T--) { scanf("%d%d", &n, &m); build(1, 1, n); while (m--) { int op, L, R, t; scanf("%d%d%d", &op, &L, &R); if (op == 0) {scanf("%d", &t); change(L, R, 1, 1, n, t);} else if (op == 1) printf("%d\n", queryMax(L, R, 1, 1, n)); else printf("%lld\n", querySum(L, R, 1, 1, n)); } } return 0; }
                                                                                                                                                                                                                                                  ^
0_0_33137523_13441.cpp:21:242: error: expected '}' at end of input


Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-07-03 11:56:59, Gzip enabled