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的更多相关文章
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive 6145 Version Controlled IDE(可持久化treap、rope)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- UVALive 6508 Permutation Graphs
Permutation Graphs Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit ...
- UVALive 6500 Boxes
Boxes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pract ...
- UVALive 6948 Jokewithpermutation dfs
题目链接:UVALive 6948 Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...
- 【暑假】[实用数据结构]UVAlive 3135 Argus
UVAlive 3135 Argus Argus Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %l ...
随机推荐
- 洛谷 P3332 [ZJOI2013]K大数查询 解题报告
P3332 [ZJOI2013]K大数查询 题目描述 有\(N\)个位置,\(M\)个操作.操作有两种,每次操作如果是\(\tt{1\ a\ b\ c}\)的形式表示在第\(a\)个位置到第\(b\) ...
- Codeforces Round #331 (Div. 2) B. Wilbur and Array
B. Wilbur and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 题解【luogu4145 上帝造题的七分钟2(花神游历各国)】
题目大意: 一个序列,支持区间开方与求和操作. 算法:线段树实现开方修改与区间求和 分析: 显然,这道题的求和操作可以用线段树来维护 但是如何来实现区间开方呢 大家有没有这样的经历:玩计算器的时候,把 ...
- C语言超大数据相加计算整理
在做ACM 1002题时,整理得到. #include<stdio.h>#include<string.h>#define MAX 1000void zero(char *s, ...
- arm架构与体系结构
1.cpu与soc 内核版本号与soc版本号由arm公司确定. 芯片型号由各半导体公司确定. soc包括cpu与一些基本内设.(一般提到CPU都指的是soc,实际上cpu只是soc的一部分). RIS ...
- C语言预处理
1.由源码到可执行程序的过程(1)源码.c->(编译)->elf可执行程序(2)源码.c->(编译)->目标文件.o->(链接)->elf可执行程序(3)源码.c- ...
- SpringMVC+MyBatis开发中指定callSettersOnNulls,可解决返回字段不全的问题
Spring+MyBatis开发过程中,在xxMapper.xml配置文件进行select查询时resultType="map",如果要查询的字段是空值,在返回的map中会出现找不 ...
- 使用Docker搭建Django,Nginx,R,Python部署环境
转载自https://blog.csdn.net/The_One_is_all/article/details/76063968 基本环境: Ubuntu 16.10 docker 17.06.0-c ...
- [Unity]扩展Hierachry的右键菜单
游戏制作到一定阶段后,一定会出现一些GameObject的"模板".比如一个敌人一定会有一个"Enemy Behaviour"."Box Collid ...
- jq_常用方法
//获取兄弟元素 $('.class').siblings() 当前元素所有的兄弟节点 $('.class').prev() 当前元素前一个兄弟节点 $('.class').prevaAll() 当前 ...