标签:描述 一个 using div 数组 += cstring cst fine
5
1 1
5 1
7 1
3 3
5 5
1
2
1
1
0
#include<iostream> #include<string> #include<cstring> #include <algorithm> #define MAX 100000 + 5 using namespace std; int n; int num[MAX]; int degree[MAX]; int lowbit(int x){ return x & (-x); } void build(int x, int v){ while(x <= MAX){ num[x] += v; x = x + lowbit(x); } } int getsum(int x){ int sum = 0; while(x > 0){ sum += num[x]; x = x - lowbit(x); } return sum; } int main(){ scanf("%d", &n); for(int i = 0; i < n; i++){ int a, b; scanf("%d %d", &a, &b); degree[getsum(a)]++; build(a, 1); } for(int i = 0; i < n; i++){ cout << degree[i] << endl; } return 0; }
标签:描述 一个 using div 数组 += cstring cst fine
原文地址:https://www.cnblogs.com/woxiaosade/p/10889771.html