0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:48:48 +00:00

#10114. 「一本通 4.1 例 2」数星星 Stars

https://loj.ac/s/1025579
This commit is contained in:
Baoshuo Ren 2021-01-03 08:41:16 +08:00 committed by Baoshuo Ren
parent c0fb0094dc
commit a7928020ad
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

43
LibreOJ/10114/10114.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <bits/stdc++.h>
using namespace std;
int n, x, y, val[33000], ans[16000];
struct node {
int x, y;
} t[16000];
int lowbit(int x) {
return x & (-x);
}
void add(int p, int v) {
while (p <= 32001) {
val[p] += v;
p += lowbit(p);
}
}
int sum(int p) {
int ans = 0;
while (p >= 1) {
ans += val[p];
p -= lowbit(p);
}
return ans;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x >> y;
x++, y++;
ans[sum(x)]++;
add(x, 1);
}
for (int i = 0; i < n; i++) {
cout << ans[i] << endl;
}
return 0;
}