Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f0bbd1a

Browse files
BIT2D less code
1 parent 0094d9d commit f0bbd1a

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

‎Library/Data Structures/BIT2D.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,8 @@ struct BIT2D {
2020
return sum;
2121
}
2222

23-
void updateArea(int xi, int yi, int xf, int yf, int val){
24-
update(xi, yi, val);
25-
update(xf+1, yi, -val);
26-
update(xi, yf+1, -val);
27-
update(xf+1, yf+1, val);
28-
}
29-
30-
int queryArea(int xi, int yi, int xf, int yf){
31-
return query(xf, yf) - query(xf, yi-1) - query(xi-1, yf) + query(xi-1, yi-1);
32-
}
23+
void updateArea(int xi, int yi, int xf, int yf, int val); //Same of BIT2DSparse
24+
int queryArea(int xi, int yi, int xf, int yf); //Same of BIT2DSparse
3325
};
3426

3527
/*LATEX_DESC_BEGIN***************************

‎Library/Data Structures/BIT2DSparse.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ struct BIT2D {
1818
bit.resize(ord.size() + 1);
1919
coord.resize(ord.size() + 1);
2020

21-
sort(begin(pts), end(pts), [&](pii &a, pii &b){
22-
return a.second < b.second;
23-
});
21+
sort(begin(pts), end(pts), [&](pii &a, pii &b){ return a.second < b.second; });
2422

2523
for(auto [x, y] : pts)
2624
for(int i=upper(ord, x); i < bit.size(); i += i&-i)
@@ -68,4 +66,4 @@ IMPORTANTE! **Offline!**
6866
BIT2D(pts); // pts -> vecotor<pii> com todos os pontos em que serão feitas queries ou updates
6967
7068
Credits: TFG (TFG50 on Git: https://github.com/tfg50/Competitive-Programming/blob/master/Biblioteca/Data%20Structures/Bit2D.cpp)
71-
*****************************LATEX_DESC_END*/
69+
*****************************LATEX_DESC_END*/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /