http://acm.nyist.net/JudgeOnline/problem.php?pid=600

只附代码好了

#include<bits/stdc++.h>
using namespace std;

;
struct node
{
    int num,id;
} s[N];
int s1[N],a[N];

bool cmp(node x,node y)
{
    return x.num<y.num;
}
int lowbit(int x)
{
    return x&-x;
}
void add(int i,int x)
{
    while(i<N)
    {
        a[i]+=x;
        i+=lowbit(i);
    }
}
int sum(int i)
{
    ;
    while(i)
    {
        ret+=a[i];
        i-=lowbit(i);
    }
    return ret;
}

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        memset(a,,sizeof(a));
        int n,m;
        scanf("%d%d",&n,&m);
        n<<=;m+=n;
        ;i<=m;i++)
        {
            scanf("%d",&s[i].num);
            s[i].id=i;
        }
        sort(s+,s+m+,cmp);

        ;
        s1[s[].id]=++cnt;
        ;i<=m;i++)
            ].num)
                s1[s[i].id]=++cnt;
            else
                s1[s[i].id]=cnt;
        ;i<=n;)
            add(s1[i++],),add(s1[i++]+,-);
        ;i<=m;i++)
            printf("%d\n",sum(s1[i]));
    }
}

nyoj 600:花儿朵朵(树状数组+坐标离散化)的更多相关文章

  1. nyoj_600:花儿朵朵(树状数组+坐标离散化)

    http://acm.nyist.net/JudgeOnline/problem.php?pid=600 只附代码好了 #include<bits/stdc++.h> using name ...

  2. WUSTOJ 1337: Car race game(C)树状数组,离散化

    题目链接:1337: Car race game 参考资料:⑴ Car race game 树状数组 棋煜,⑵ 树状数组,⑶ 离散化 补充资料:⑴ qsort,⑵ 二分查找 Description B ...

  3. 线段树&树状数组与离散化的妙用

    牛客2019多校联盟Day7 Fine the median 题意:  每次给数组插入区间[Li,Ri] 内的所有数,每操作一次查询中位数. 遇到这题真的算是巧合,然而就是这种冥冥之中的缘分,给了我线 ...

  4. HDU 3333 | Codeforces 703D 树状数组、离散化

    HDU 3333:http://acm.hdu.edu.cn/showproblem.php?pid=3333 这两个题是类似的,都是离线处理查询,对每次查询的区间的右端点进行排序.这里我们需要离散化 ...

  5. POJ-2299 Ultra-QuickSort (树状数组,离散化,C++)

    Problem Description In this problem, you have to analyze a particular sorting algorithm. The algorit ...

  6. HDU 5877 Weak Pair(树状数组+dfs+离散化)

    http://acm.hdu.edu.cn/showproblem.php?pid=5877 题意: 给出一棵树,每个顶点都有权值,现在要你找出满足要求的点对(u,v)数,u是v的祖先并且a[u]*a ...

  7. 【(待重做)树状数组+dp+离散化】Counting Sequences

    https://www.bnuoj.com/v3/contest_show.php?cid=9149#problem/G [题意] 给定一个数组a,问这个数组有多少个子序列,满足子序列中任意两个相邻数 ...

  8. D. Nested Segments(树状数组、离散化)

    题目链接 参考博客 题意: 给n个线段,对于每个线段问它覆盖了多少个线段. 思路: 由于线段端点是在2e9范围内,所以要先离散化到2e5内(左右端点都离散化了,而且实际上离散化的范围是4e5),然后对 ...

  9. 算法笔记求序列A每个元素左边比它小的数的个数(树状数组和离散化)

    #include <iostream> #include <algorithm> #include <cstring> using namespace std ; ...

随机推荐

  1. RabbitMQ生产者消费者模型构建(三)

    ConnectionFactory:获取连接(地址,端口号,用户名,密码,虚拟主机等) Connection:一个连接 Channel:数据通信信道,可发送.接收消息 Queue:具体的消息存储队列 ...

  2. CSS3订单提交按钮Loading代码

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"& ...

  3. django缓存优化(三)

    This should give you a feel for how this module operates:: import memcache mc = memcache.Client(['12 ...

  4. 洛谷P1546 最短网络 Agri-Net(最小生成树,Kruskal)

    洛谷P1546 最短网络 Agri-Net 最小生成树模板题. 直接使用 Kruskal 求解. 复杂度为 \(O(E\log E)\) . #include<stdio.h> #incl ...

  5. Windows命令学习

    总: 1.window dos命令不区分大小写  2.指令参数 /a   -a 等价 更倾向于 / 3.命令有疑问: CMD输入help 或者单条命令 /? help time /? 用到的实用命令总 ...

  6. PHP Yii框架中使用smarty模板

    第一种方法 按照YII系统的办法生成视图觉得有点麻烦,觉得用smarty更省事.尝试着把smarty模板加进来了. date_default_timezone_set("PRC") ...

  7. 单击EasyUI的datagrid行时不选中

    单击EasyUI的datagrid行时不选中,行背景色不变,点击选择框checkbox时选中该行 核心代码: $("#msgList").datagrid({        url ...

  8. < 利用Python进行数据分析 - 第2版 > 第五章 pandas入门 读书笔记

    <利用Python进行数据分析·第2版>第五章 pandas入门--基础对象.操作.规则 python引用.浅拷贝.深拷贝 / 视图.副本 视图=引用 副本=浅拷贝/深拷贝 浅拷贝/深拷贝 ...

  9. [Linux] 002 预备知识

    1. 开源软件 (1) 常见开源软件 Apache NGINXTM MySQL PHP Saamba mongoDB Python Ruby Sphinx -- (2) 开源软件的特点 绝大多数开源软 ...

  10. spring-第十二篇之两种后处理器

    1.扩展IoC容器使用后处理器扩展 bean后处理器:对容器中的bean进行后处理,也就是额外的加强. 容器后处理:对IoC容器进行后处理,增强容器功能. 2.bean后处理器      负责处理容器 ...