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. ci框架学习告一段落,总结一下

    从网上弄了一张框架学习思维导图,从图中就可以看出ci用了设计模式中的MVC架构,使得用起来很简单方便 用了大概两个星期开发了一个<文章管理系统>觉得开发过程中学到了很多,挺不错的,而且在学 ...

  2. NodeMCU入门(4):搭建Web服务器,配置网络连接

    准备工作 1.NodeMCU模块 2.ESPlorer v0.2.0-rc6 3.NodeMCU-HTTP-Server 搭建web服务器 下载https://github.com/wangzexi/ ...

  3. 编写原生JS的insertAfter函数

    DOM里有insertBefore函数,但没有insertAfter函数,所以自己编写一个该函数: function insertAfter(newElement, targetElement){ v ...

  4. go的基本概念

    go的基础结构主要由下面的几个部分组成 1:包的声明 2:引入包 3:函数 4:变量 5:语句表达式 6注释 package main import "fmt" func main ...

  5. spring boot 入门操作(三)

    spring boot入门操作 devtools热部署 pom dependencies里添加依赖 <dependency> <groupId>org.springframew ...

  6. Disruptor——一种可替代有界队列完成并发线程间数据交换的高性能解决方案

    本文翻译自LMAX关于Disruptor的论文,同时加上一些自己的理解和标注.Disruptor是一个高效的线程间交换数据的基础组件,它使用栅栏(barrier)+序号(Sequencing)机制协调 ...

  7. eclipse debug URLClassPath.getLoader(int) file

    版权声明:本文为博主原创文章,未经博主允许不得转载. URLClassPath.getLoader 在用Eclipse调试Java程序时,新手遇到的一个问题是断点老是执行不到,弹出URLClassPa ...

  8. IE6不支持position:fixed的解决方法

    解决IE6不支持position:fixed的方法,非常简单,具体调用请参考下面: /*让position:fixed在IE6下可用! */ .fixed-top /* 头部固定 */{positio ...

  9. HTML4,HTML5,XHTML 之间有什么区别?

    原始日期:2014-10-25 14:12 我来从HTML的历史谈谈他们3者的区别.在HTML的早期发展中,W3C成立之前,很多标准的制定都是在浏览器的开发者们互相讨论的情况下完成的,比如HTML 2 ...

  10. RabbitMQ windows安装官方文档翻译!

    RabbitMQ Windows安装和配置 下载地址 官网windows下载地址: http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/r ...