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 ...
随机推荐
- BZOJ4869:[SHOI2017]相逢是问候——题解
http://www.lydsy.com/JudgeOnline/problem.php?id=4869 题面复制于洛谷:https://www.luogu.org/problemnew/show/P ...
- CF25E:Test——题解
https://vjudge.net/problem/CodeForces-25E 题目大意:给三个字符串,求最小串,使得前三个串都是它的子串. ———————————————— 这题虽然是看哈希的时 ...
- Linux实验三
主要参考课本第二章所学习内容 (信息的表示和处理) 所有重点内容: 信息存储 整数表示/运算 浮点数 一 十六进制表示 0~9 A~F 0000~1111 注:(主要参考课本P22) 字 字长: ...
- POJ1201:Intervals(差分约束)
差分约束经典题.设s[i]为前缀和,则有 s[i]-s[i-1]<=1 (i往i-1连-1的边) s[i]>=s[i-1] (i-1往i连0的边) s[b]-s[a-1]>=c (a ...
- FreeRTOS ------ 栈、堆、任务栈
1.任务的栈资源(创建任务分配的资源,单位是4字节)来自 configTOTAL_HEAP_SIZE 定义的堆,如果任务栈总量超过 configTOTAL_HEAP_SIZE,任务创建失败: 2.如果 ...
- session 超时设置
Java Web开发Session超时设置 博客分类: Java Web 在Java Web开发中,Session为我们提供了很多方便,Session是由浏览器和服务器之间维护的.Session超时理 ...
- 洛谷 P3730 曼哈顿交易
https://www.luogu.org/problem/show?pid=3730 题目背景 will在曼哈顿开了一家交易所,每天,前来买卖股票的人络绎不绝. 现在,will想要了解持股的情况.由 ...
- vijos 1071 01背包+输出路径
描述 过年的时候,大人们最喜欢的活动,就是打牌了.xiaomengxian不会打牌,只好坐在一边看着. 这天,正当一群人打牌打得起劲的时候,突然有人喊道:“这副牌少了几张!”众人一数,果然是少了.于是 ...
- jquery字符串序列化方法总结
在jquery中字符串序列化方法包括有param() .serialize() .serializeArray(),在这里对其常用做法进行总结. $.param()方法这是serialize()方法的 ...
- 持续集成之Jenkins安装部署
1.系统环境和安装java环境 [root@devops ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) 安装java ...