题意:平面坐标上有n个怪物,每个怪物有一个rank值,代表x坐标和y坐标都不大于它本身的怪物数(不包括本身)
思路:对x y坐标从小到大排序,x优先排序,用数状数组计算y坐标小于它的数量
AC代码:
#include "iostream"#include "string.h"#include "stack"#include "queue"#include "string"#include "vector"#include "set"#include "map"#include "algorithm"#include "stdio.h"#include "math.h"#define ll long long#define bug(x) cout<<<" "<<"UUUUU"< 0){ ret+=Y[y]; y-=lowbit(y); } return ret;}int main(){ //ios::sync_with_stdio(false),cin.tie(0);cout.tie(0); cin>>n; for(int i=1; i<=n; ++i){ cin>>P[i].x>>P[i].y; ma=max(ma,P[i].y), ma=max(ma,P[i].y); } sort(P+1,P+1+n); for(int i=1; i<=n; ++i){ int cnt=sum(P[i].y); ans[cnt]++; add(P[i].y,1); } for(int i=0; i