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. SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6]

    SLF4J:你的SLF4J绑定请求的1.6版不兼容[1.5.5,1.5.6] 在lib中,此时slf4j的版本是1.5.6,而slf4j-log4j的版本是1.6.由于版本的不兼容性,导致了这个错误. ...

  2. python发送消息到ipmsg

    from socket import * #利用socket模块生成套接字s = socket(AF_INET,SOCK_DGRAM) #定义一个元组,包含ip地址,和端口号,ip地址必须为字符串,端 ...

  3. What is httpcontext

    https://docs.microsoft.com/en-us/dotnet/api/system.web.httpcontext?view=netframework-4.8 Encapsulate ...

  4. ImportError: libsybdb.so.5: cannot open shared object file: No such file or directory pymssql linux 问题解决 搭建驱动

    [root@hadoop1 nlp]# python sqlserver_t.py Traceback (most recent call last):  File "sqlserver_t ...

  5. yum python mysql

    lrwxrwxrwx root root Jun : pyspark -> /etc/alternatives/pyspark lrwxrwxrwx root root Jul : python ...

  6. pycharm5.0.4简易使用说明

    前言:学习自动化,需要使用pycharm,以下是简易使用说明 1.注册破解 2.行号和背景色 3.打断点 1.注册破解 打开pycharm5.0.4,点击菜单栏的help->register.. ...

  7. javascript 调试 使用console.table()

    或许你已经习惯了console.log()来调试js,非常使用,但是今天微博看到console.table()调试javascript,和console.log()类似,主要区别在于: 主要用来输出对 ...

  8. EasyUI在子tab基础上再打开新的tab标签页

    var title = "xxxx"; var content = '<iframe scrolling="auto" frameborder=" ...

  9. android 学习路线

    转载来源:https://blog.csdn.net/lixuce1234/article/details/77947405 jixiaohua发了一篇一个老鸟也发了一份他给公司内部小伙伴整理的路线图 ...

  10. Cnblogs 的 MetaWeblog 的接口发生了变化

    Cnblogs 的 MetaWeblog 的接口发生了变化 */--> Cnblogs 的 MetaWeblog 的接口发生了变化 最近把 emacs 重新配置了一下,把 cnblogs 包也重 ...