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. BZOJ4868:[SHOI2017]期末考试——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=4868 题目复制于洛谷:https://www.luogu.org/problemnew/show/P ...

  2. 爬虫实例——爬取淘女郎相册(通过selenium、PhantomJS、BeautifulSoup爬取)

    环境 操作系统:CentOS 6.7 32-bit Python版本:2.6.6 第三方插件 selenium PhantomJS BeautifulSoup 代码 # -*- coding: utf ...

  3. 淘淘相关DTO

    result 用于Controller层返回值或Controller于service层之间返回值 package com.taotao.common.pojo; import java.util.Li ...

  4. JS this的指向

    总结:this指向调用函数的那个对象. 在不同的应用场景this的指向有所不同,但细细思考都符合总结的意思. 场景一:一般的函数调用 这种常见的函数调用方式this指向的是window,因为相当于是w ...

  5. ACM1881 01背包问题应用

    01背包问题动态规划应用 acm1881毕业bg 将必须离开的时间限制看作背包容量,先将他们由小到大排序,然后在排完序的数组中对每个实例都从它的时间限制开始(背包容量)到它的延长时间进行遍历: #in ...

  6. zookeeper源码分析之leader选举

    zookeeper提供顺序一致性.原子性.统一视图.可靠性保证服务zookeeper使用的是zab(atomic broadcast protocol)协议而非paxos协议zookeeper能处理并 ...

  7. Stirling数笔记

    Updating.... 这几个玩意儿要记的东西太多太乱所以写blog整理一下 虽然蒯的成分会比较多全部 我居然开始记得写blog了?? 第一类 这里讨论的是无符号类型的. OEIS编号A130534 ...

  8. elasticsearch中Node的创建

    要连接到集群,首先要告诉集群:你是谁,你有什么特征.在es中体现为实例化节点,elasticsearch通过org.elasticsearch.node.NodeBuilder的build()或者no ...

  9. Item 8 覆盖equals时请遵守通用约定

    在覆盖equals方法的时候,你必须要遵守它的通用约定,不遵守,写出来的方法,会出现逻辑错误.下面是约定的内容:   equals方法实现了等价关系:   自反性.对于任何非null的引用值,x.eq ...

  10. MSSQL备份脚本

    ) ) ) ),),':',''),' ',''),'-',''),'.','') set @name=N'DEMO'+@temp+'-完整 数据库 备份' set @disk=N'F:\Backup ...