이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
map<pair<int,int>,int> tree;
int get(int x,int y){
int ans = 0;
while(x){
int tempy = y;
while(tempy){
if(tree.count({x,tempy}))ans+=tree[{x,tempy}];
tempy-=tempy&-tempy;
}
x-=x&-x;
}
return ans;
}
void add(int x,int y){
while(x<=100001){
int tempy = y;
while(tempy<=100001){
tree[{x,tempy}]++;
tempy+=tempy&-tempy;
}
x+=x&-x;
}
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,q;
cin >> n >> q;
for(int i=1;i<=n;i++){
int x,y;cin>>x>>y;
x = 100001-x;
y = 100001-y;
add(x,y);
}
for(int i=1;i<=q;i++){
int a,b,c;cin>>a>>b>>c;
a = 100001-a;
b = 100001-b;
cout << get(a,b) << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |