UVALive 6426

/**
题意:给一个n*m的矩阵,求某一个区间的数的数量
做法:刚开始想用树状数组,但是RE,题目中说数据是从二进制流中读入,
用scanf会挂掉 所以用fread
      读入 size_t fread(void array[],size_t size ,size_t count,stream);
      array[] 用与接受数据的内存的地址
      size 用于读取的字节数,单位是字节  
      count 要进行读写多少个size字节的数据项,每个元素是size字节
       stream :输入流
      long long a;
      fread(&a,sizeof(long long),1,stdin);
      char ch[10];
      fread(ch,sizeof(char),10,stdin);
**/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <cmath>
using namespace std;
int a[][];
int main()
{
int n,m;
int c;
fread(&n,sizeof(int),,stdin);
fread(&m,sizeof(int),,stdin);
for(int i=;i<n;i++)
{
fread(a[i],sizeof(int),m,stdin);
}
int l,r;
int last = m;
while(fread(&l,sizeof(int),,stdin))
{
fread(&r,sizeof(int),,stdin);
int ans = ;
for(int i=;i<n;i++)
{
if(a[i][] > r) break;
int ll = lower_bound(a[i],a[i]+last,l)-a[i];
int rr = upper_bound(a[i],a[i]+last,r) -a[i];
if(rr <= ll) continue;
ans += rr - ll;
}
printf("%d\n",ans);
}
return ;
}

UVALive 6426的更多相关文章

  1. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  2. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  3. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

  4. 思维 UVALive 3708 Graveyard

    题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...

  5. UVALive 6145 Version Controlled IDE(可持久化treap、rope)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  6. UVALive 6508 Permutation Graphs

    Permutation Graphs Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit ...

  7. UVALive 6500 Boxes

    Boxes Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Pract ...

  8. UVALive 6948 Jokewithpermutation dfs

    题目链接:UVALive 6948  Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...

  9. 【暑假】[实用数据结构]UVAlive 3135 Argus

    UVAlive 3135 Argus Argus Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %l ...

随机推荐

  1. BZOJ 1342: [Baltic2007]Sound静音问题 | 单调队列维护的好题

    题目: 给n个数字,一段合法区间[l,l+m-1]要求max-min<=c 输出所有合法区间的左端点,如果没有输出NONE 题解: 单调队列同时维护最大值和最小值 #include<cst ...

  2. BZOJ1011 [HNOI2008]遥远的行星 【奇技淫巧】

    1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec  Memory Limit: 162 MBSec  Special Judge Submit: 5058  Solve ...

  3. Vue项目搭建过程

    环境搭建:mac+nodejs+npm #安装node.js : $ brew install node #安装vue-cil: $ npm install -g vue-cli 注:官网下载安装no ...

  4. 一些实用的JQuery代码片段收集

    本文将展示50个非常实用的JQuery代码片段,这些代码能够给你的JavaScript项目提供帮助.其中的一些代码段是从jQuery1.4.2才开始支持的做法,另一些则是真正有用的函数或方法,他们能够 ...

  5. array_value

    <?php $a=array("Name"=>"Bill","Age"=>"60","Cou ...

  6. Javascript利用递归实现数组的快速排序

    // 定义快速排序方法 function quickSort(arr){ // 设置递归的终止条件 if( arr.length <= 1){ return arr; } // 获得数组arr的 ...

  7. $.ajax() 方法的理解

    jquery中的ajax方法理解,AJAX即“Asynchronous Javascript And XML”(异步JavaScript和XML),是指一种创建交互式网页应用的网页开发技术.AJAX ...

  8. Lodash js数据操作库

    https://lodash.com/docs/4.17.4

  9. List<Hashtable>排序

    hashtableList.Sort( delegate (Hashtable a, Hashtable b) { DateTime dateTime1 = (DateTime)a["ber ...

  10. 一道lambda表达式题目

    #include <iostream> #include <functional> using namespace std; auto Pair = [](auto u, au ...