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. 动态规划 List

    例题 #A 传纸条(Accepted)    #B 乘积最大 (Unaccepted)    #C 石子合并 (Accepted)    #D 加分二叉树 (Unaccepted)    #E 没有上 ...

  2. sql-hive笔试题整理 1 (学生表-成绩表-课程表-教师表)

    题记:一直在写各种sql查询语句,最长的有一百多行,自信什么需求都可以接,可......,想了想,可能一直在固定的场景下写,平时也是以满足实际需求为目的,竟不知道应试的题都是怎么出的,又应该怎么做.遂 ...

  3. oracle系统对象

    select * from all_tab_comments-- 查询所有用户的表,视图等 select * from user_tab_comments  -- 查询本用户的表,视图等 select ...

  4. I am going to India on a business trip

    I think English is very important,and learn it must perseverant.So I determined to write diary on Bo ...

  5. windows下使用pycharm开发基于ansible api的python程序

    Window下python安装ansible,基于ansible api开发python程序 在windows下使用pycharm开发基于ansible api的python程序时,发现ansible ...

  6. 备份mysql的shell

    • #!/bin/bash• file_name=`date +%Y%m%d%H%M%S`• db_path='/usr/local/db_back/'• mysqldump -ulepus -p12 ...

  7. Python笔记(十三)_os模块和os.path模块

    os模块中关于文件/目录常用的函数使用方法 getcwd() 返回当前工作目录 chdir(path) 改变工作目录 listdir(path='.') 列举指定目录中的文件名('.'表示当前目录,' ...

  8. Python3-问题整理

    TypeError: a bytes-like object is required, not 'str' json.decoder.JSONDecodeError: Extra data json文 ...

  9. centos7 nginx完整支持thinkphp pathinfo模式开启方法

    thinkphp运行在linux+nginx,如何开启pathinfo模式,我是完整测试过了,没问题的,在thinkphp配置文件 开启    'URL_MODEL'   =>  1,   1代 ...

  10. 选择指定的MySQL数据库

    <?php /******************************** *** 功能:选择指定的MySQL数据库 *********************************/ ? ...