Compile Error
foo.cc:13:21: error: expected ',' or ')', found "<<" 13 | #define lc(node << 1); | ^~ foo.cc:14:16: error: expected parameter name, found "(" 14 | #define rc((node << 1) + 1 ) | ^ foo.cc: In member function 'void STL::push(int, int, int)': foo.cc:23:20: error: return-statement with a value, in function returning 'void' [-fpermissive] 23 | return 0; | ^ foo.cc:27:18: error: 'lc' was not declared in this scope; did you mean 'll'? 27 | lazy[lc] = lazy[lc] + lazy[node]; | ^~ | ll foo.cc:28:18: error: 'rc' was not declared in this scope 28 | lazy[rc] = lazy[rc] + lazy[node]; | ^~ foo.cc: In member function 'void STL::pull(int)': foo.cc:36:21: error: 'lc' was not declared in this scope; did you mean 'll'? 36 | T[node] = T[lc] + T[rc]; | ^~ | ll foo.cc:36:29: error: 'rc' was not declared in this scope 36 | T[node] = T[lc] + T[rc]; | ^~ foo.cc: In member function 'void STL::build(int, int, int)': foo.cc:45:11: error: 'lc' was not declared in this scope; did you mean 'll'? 45 | build(lc,b,mid); | ^~ | ll foo.cc:46:11: error: 'rc' was not declared in this scope 46 | build(rc,mid+1,e); | ^~ foo.cc: In member function 'void STL::update(int, int, int, int, int, int)': foo.cc:60:16: error: 'lc' was not declared in this scope; did you mean 'll'? 60 | update(lc,b,mid,i,j,v); | ^~ | ll foo.cc:61:16: error: 'rc' was not declared in this scope 61 | update(rc,mid+1,e,i,j,v); | ^~ foo.cc: In member function 'long long int STL::query(int, int, int, int, int)': foo.cc:73:30: error: 'lc' was not declared in this scope; did you mean 'll'? 73 | return combine(query(lc,b,mid,i,j),query(rc,mid+1,e,i,j)); | ^~ | ll foo.cc:73:50: error: 'rc' was not declared in this scope 73 | return combine(query(lc,b,mid,i,j),query(rc,mid+1,e,i,j)); | ^~ foo.cc: In function 'void solve()': foo.cc:81:14: error: 'o' was not declared in this scope 81 | memset(A,o,sizeof(A)); | ^ foo.cc:83:14: error: no matching function for call to 'STL::build()' 83 | one.build(); | ~~~~~~~~~^~ foo.cc:38:6: note: candidate: 'void STL::build(int, int, int)' 38 | void build(int node , int b, int e){ | ^~~~~ foo.cc:38:6: note: candidate expects 3 arguments, 0 provided
Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(x) x.begin(), x.end()
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define print(v) for(auto e:v) cout<<e<<" "; cout<<endl;
const int N = 1e5+6;
int A[N];
struct STL{
#define lc(node << 1);
#define rc((node << 1) + 1 )
ll T[4*N],lazy[4*N];
STL(){
memset(T,0,sizeof T);
memset(lazy,0,sizeof lazy);
}
inline void push(int node ,int b,int e) {
if(lazy[node] == 0){
return 0;
}
T[node] = T[node] + lazy[node] *(e - b +1);
if(b != e) {
lazy[lc] = lazy[lc] + lazy[node];
lazy[rc] = lazy[rc] + lazy[node];
}
lazy[node] = 0;
}
inline long long combine(ll a,ll b){
return max(a,b);
}
inline void pull(int node) {
T[node] = T[lc] + T[rc];
}
void build(int node , int b, int e){
lazy[node] =0;
if(b == e){
T[node] = A[b];
return;
}
int mid = (b + e) / 2;
build(lc,b,mid);
build(rc,mid+1,e);
pull(node);
}
void update(int node ,int b, int e, int i, int j, int v){
push(node,b,e);
if(j < b || e<i){
return;
}
if(i <= b && e <= j){
lazy[node] = v;
push(node,b,e);
return;
}
int mid = (b+e) /2;
update(lc,b,mid,i,j,v);
update(rc,mid+1,e,i,j,v);
pull(node);
}
long long query(int node, int b,int e,int i,int j){
push(node,b,e);
if(i > e || b >j){
return 0;
}
if(i <=b && e<=j){
return T[node];
}
int mid = (b+e) /2;
return combine(query(lc,b,mid,i,j),query(rc,mid+1,e,i,j));
}
};
void solve() {
int n; cin >> n;
memset(A,o,sizeof(A));
STL one;
one.build();
for(int i = 0; i<n ; i++) {
cin >>A[i];
}
int Q; cin >> Q;
while(Q--){
int a; cin >> a;
if(a == 1){
ll l,r,x;cin >>l >> r >> x;
one.update(n,0,1,l,r,x);
}
else{
ll l,r; cin >> l>> r;
ll nts = one.query(n,0,1,l,r);
cout << nts << endl;
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1; cin >> t;
while(t--){
solve();
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1211 Range MAX
- Contest
- LUCC Presents Kick & Code Intra LU Programming Contest
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-09-01 07:44:43
- Judged At
- 2025-09-01 07:44:43
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes