0_0_22455085_21544.cpp:43:741: error: expected '}' at end of input
} type query(int L,int R,int l,int r,int rt){ if(L <= l && R >= r){ return sum[rt]; } PushDown(rt,r-l+1); int mid = (l+r)>>1; type ans = 0; if(L <= mid)ans += query(L,R,lson); if(R > mid)ans += query(L,R,rson); return ans; } }; int main() { int N,M,cas=0; while(~scanf("%d",&N)){ scanf("%d",&M); for (int i = 1; i <= N; i++) scanf("%I64d",&m[i]); Segment_tree tree; tree.build(1,N,1); char s[2]={}; int l,r,add; while(M--){ scanf("%s",s); if(s[0] == 'Q'){ scanf("%d %d",&l,&r); if(l > r)swap(l,r); printf("%I64d\n",tree.query(l,r,1,N,1)); }else if(s[0] == 'C'){ scanf("%d %d %d",&l,&r,&add); if(l > r)swap(l,r); tree.update(l,r,add,1,N,1); } } } return 0; }
^
0_0_22455085_21544.cpp: In member function 'void Segment_tree::update(int, int, int, int, int, int)':
0_0_22455085_21544.cpp:43:47: error: a function-definition is not allowed here before '{' token
} type query(int L,int R,int l,int r,int rt){ if(L <= l && R >= r){ return sum[rt]; } PushDown(rt,r-l+1); int mid = (l+r)>>1; type ans = 0; if(L <= mid)ans += query(L,R,lson); if(R > mid)ans += query(L,R,rson); return ans; } }; int main() { int N,M,cas=0; while(~scanf("%d",&N)){ scanf("%d",&M); for (int i = 1; i <= N; i++) scanf("%I64d",&m[i]); Segment_tree tree; tree.build(1,N,1); char s[2]={}; int l,r,add; while(M--){ scanf("%s",s); if(s[0] == 'Q'){ scanf("%d %d",&l,&r); if(l > r)swap(l,r); printf("%I64d\n",tree.query(l,r,1,N,1)); }else if(s[0] == 'C'){ scanf("%d %d %d",&l,&r,&add); if(l > r)swap(l,r); tree.update(l,r,add,1,N,1); } } } return 0; }
^
0_0_22455085_21544.cpp:43:249: error: expected '}' at end of input
} type query(int L,int R,int l,int r,int rt){ if(L <= l && R >= r){ return sum[rt]; } PushDown(rt,r-l+1); int mid = (l+r)>>1; type ans = 0; if(L <= mid)ans += query(L,R,lson); if(R > mid)ans += query(L,R,rson); return ans; } }; int main() { int N,M,cas=0; while(~scanf("%d",&N)){ scanf("%d",&M); for (int i = 1; i <= N; i++) scanf("%I64d",&m[i]); Segment_tree tree; tree.build(1,N,1); char s[2]={}; int l,r,add; while(M--){ scanf("%s",s); if(s[0] == 'Q'){ scanf("%d %d",&l,&r); if(l > r)swap(l,r); printf("%I64d\n",tree.query(l,r,1,N,1)); }else if(s[0] == 'C'){ scanf("%d %d %d",&l,&r,&add); if(l > r)swap(l,r); tree.update(l,r,add,1,N,1); } } } return 0; }
^
0_0_22455085_21544.cpp: In member function 'int Segment_tree::main()':
0_0_22455085_21544.cpp:43:578: error: 'class Segment_tree' has no member named 'query'
} type query(int L,int R,int l,int r,int rt){ if(L <= l && R >= r){ return sum[rt]; } PushDown(rt,r-l+1); int mid = (l+r)>>1; type ans = 0; if(L <= mid)ans += query(L,R,lson); if(R > mid)ans += query(L,R,rson); return ans; } }; int main() { int N,M,cas=0; while(~scanf("%d",&N)){ scanf("%d",&M); for (int i = 1; i <= N; i++) scanf("%I64d",&m[i]); Segment_tree tree; tree.build(1,N,1); char s[2]={}; int l,r,add; while(M--){ scanf("%s",s); if(s[0] == 'Q'){ scanf("%d %d",&l,&r); if(l > r)swap(l,r); printf("%I64d\n",tree.query(l,r,1,N,1)); }else if(s[0] == 'C'){ scanf("%d %d %d",&l,&r,&add); if(l > r)swap(l,r); tree.update(l,r,add,1,N,1); } } } return 0; }
^
0_0_22455085_21544.cpp: At global scope:
0_0_22455085_21544.cpp:43:741: error: expected unqualified-id at end of input
} type query(int L,int R,int l,int r,int rt){ if(L <= l && R >= r){ return sum[rt]; } PushDown(rt,r-l+1); int mid = (l+r)>>1; type ans = 0; if(L <= mid)ans += query(L,R,lson); if(R > mid)ans += query(L,R,rson); return ans; } }; int main() { int N,M,cas=0; while(~scanf("%d",&N)){ scanf("%d",&M); for (int i = 1; i <= N; i++) scanf("%I64d",&m[i]); Segment_tree tree; tree.build(1,N,1); char s[2]={}; int l,r,add; while(M--){ scanf("%s",s); if(s[0] == 'Q'){ scanf("%d %d",&l,&r); if(l > r)swap(l,r); printf("%I64d\n",tree.query(l,r,1,N,1)); }else if(s[0] == 'C'){ scanf("%d %d %d",&l,&r,&add); if(l > r)swap(l,r); tree.update(l,r,add,1,N,1); } } } return 0; }
^
|