ZOJ 3317 Murder in Restaurant模拟(解题报告)

项目安全等保测评加固手册 安全等级测评的目的是通过对目标系统在安全技术及管理方面的测评,对目标系统的安全技术状态及安全管理状况做出初步判断,给出目标系统在安全技术及安全管理方面与其相应安全等级保护要求之间的差距。测评结论作为委托方进一步完善系统安全策略及安全技术防护措施依据!! 阅读详情

Description

Murder in closet happened again in a small restaurant and Conan went there to collect evidence with Kogoro. After they reached the restaurant, they got a list of renters that lived in this restaurant recently. Yet the list was so long that they couldn’t get the useful information from it. As an assistant of Conan, you must have been ready to help him to get the information on which rooms the renters have lived in.

 

Input

There are no more than 20 test cases. The first line of each test case contains two integers n and m, indicating the number of renters and the rooms of the restaurant (0 < n, m <= 100). The i-th line of the next n lines contains two integers t1 and t2, the day when they wanted to check in and to leave (0 < t1 < t2 <= 1000).

Each renter rends exactly one room and their check-in days are distinct. Each time a renter came, the owner would give him/her an available room with minimum room number if there were still empty rooms. Otherwise the renter would leave at once and never come back again. Note that rooms are always returned in morning and rented in afternoon. The input is ended with two zeroes.

Output

For each test case, output n lines of integers. The i-th integer indicates the room number of the i-th renter. The rooms are numbered from 1. If someone didn’t live in this restaurant, output 0 in the corresponding line.

Sample Input 

2 5
1 3
2 4
4 2
1 5
2 3
3 5
4 5
0 0

Sample Output 

1
2
1
2
2
0
说下题目大意:给出来住宿的人数n,旅馆有m间房,给出n个人的入住的时间和离开的时间,问这n个人住的是哪间房子,输出房号,没有入住的输出0.
这个题目主要是数据可能没有排序,所以要先排序,然后模拟就好了。
题目推荐:2颗星

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct point
{
	int to,from;//入住时间 和离开时间 
	int num,room; 
};
 
point room[101];
point temp[101];
int n,m;
 
int cmp(point a,point b)
{
	if(a.from!=b.from)
	{
		return a.from<b.from; 
	}
	else
	{
		return a.to<b.to;
	}
}
 
int cmp1(point a,point b)
{
	return a.num<b.num; 
}
 
int find(int from,int to,int m)
{
	int i;
	for(i=1;i<=m;i++)
	{
		if(room[i].from==0&&room[i].to==0)
		{//为初始的0,当然是可以入住的 
			room[i].from=from;
			room[i].to=to;
			return i;
		}
		else if(room[i].to>from)
		{//大于就不能住了,继续找 
			continue;
		}
		else if(room[i].to<=from)
		{//这个可以住,那就住下了吧 
			room[i].from=from;
			room[i].to=to;
			return i;
		}
	}
	return 0;
}
 
int main()
{
	int i;
	int to,from;
	while(scanf("%d%d",&n,&m))
	{
		memset(room,0,sizeof(room));
		if(n==0&&m==0)
		{
			break;
		}
		for(i=0;i<n;i++)
		{
			scanf("%d%d",&temp[i].from,&temp[i].to);
			temp[i].num=i;//记录查询的先后顺序,输出要按照这个顺序输出 
		}
		sort(temp,temp+n,cmp);//按照入住的时间从小到大排序 
		for(i=0;i<n;i++)
		{
			temp[i].room=find(temp[i].from,temp[i].to,m);//找哪个房间是可以住的,存起来 
		}
		sort(temp,temp+n,cmp1);//还原查询是的顺序 
		for(i=0;i<n;i++)
		{
			printf("%d\n",temp[i].room);
		}
	}
	return 0;
}




SAP-MM-采购过账接口(与WMS集成)-代码 1、判断传入值非空检验; 2、判断过账日期是否允许在当前期间; 3、判断是否为集采订单业务,是否审批完成; 4、判断是否发布标准成本发布(此业务场景与价格控制3+S有关) 5、保存日志表; 6、判断业务公司订单审批状态; 7、创建STO交货单、集采公司订单过账、STO公司间创建交货单、交货单过账(两步法)、过账失败回滚(冲销交货、删除交货单、冲销集采入库) 阅读详情

相关推荐

树莓派5搭建ROS1开发环境:从系统安装到环境变量配置

本文详细指导如何在树莓派5上搭建ROS1开发环境。针对树莓派OS非标准安装路径导致的常见CMake报错问题,提供了从系统烧录、一键安装ROS到关键环境变量配置的完整解决方案,确保工作空间能成功编译,助力机器人项目开发。

weixin_29159127的博客 384

ZOJ 3317 Murder in Restaurant(数学)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3317Murder in closet happened again in a small restaurant and Conan went there to collect evidence with Kogoro. After they reached the...

977

嵌入式开发也玩“全家桶”?手把手教你用CLion+PyOCD调试APM32,比OpenOCD更简单

本文详细介绍了如何使用CLion和PyOCD组合进行APM32嵌入式开发,提供从环境配置到实战调试的完整指南。相比传统工具如Keil和OpenOCD,这套方案更轻量、易用,特别适合现代开发者需求,涵盖CMake配置、PyOCD调试技巧及常见问题解决。

weixin_42543046的博客 463

zoj3317——Murder in Restaurant

题目大意:一个旅馆来一个住户就把他安排到房间号最小的空房间,如果没有空房间这个人就会离开,根据住户的入住和离开,判断住户所住的房间号 输入:(可以有不超过20个case,输入以0 0结束)             n  m(0             第i个住户的入住日期t1  离开日期t2 (0 输出:每个住户住的房间号(各占一行,如果没有入住就输出0) 分析:模拟题(有点贪心的思

tzyshiwolaogongya的博客 275

5款免费二进制编辑器横向评测:从HxD到ImHex谁更适合你?

本文对5款免费二进制编辑软件进行深度横向评测,包括HxD、wxHexEditor、010 Editor、ImHex和GNU Emacs,涵盖从轻量级到专业级的各种需求。评测基于文件处理能力、编辑功能、分析工具等核心维度,为开发者、逆向工程师和安全研究人员提供实用选择指南,帮助用户根据具体场景选择最适合的二进制编辑工具。

weixin_29278805的博客 371

Qt实现思维导图功能5『纵向分布模式』

思维导图纵向分布模式:模式一

浮生流年的博客 1055

zoj3317Murder in Restaurant

链接1: http://openoj.awaysoft.com:8080/judge/contest/view.action?cid=269#problem/C  链接2: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3317     Murder in Restaurant Time Limit:1000MS

JHC23的专栏 602

【x264编码器】章节1——x264编码流程及基于x264的编码器demo

提供了一种方便的方式来根据指定的配置profile应用相应的设置到 x264 参数结构体上。不同的配置文件类型会对参数结构体进行不同的修改,以满足特定的编码需求。然后是编码器参数,包括帧参考数、最大关键帧间隔、最小关键帧间隔、B 帧数、场景切换阈值等。结构体的成员进行赋值,将其初始化为默认值。之后是一些编码器设置,如去块滤波、CABAC 编码、码率控制方法、参考帧压缩系数等。接下来是一系列与视频属性相关的参数,如色度格式、宽度、高度、宽高比等。然后是一些与日志输出、分析类型、量化矩阵等相关的参数。

vcvdv123的博客 5742

HDU 1018 Big Number数论(解题报告)

Problem Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you ar

CSUST_ACM的专栏 2055

通过miniconda conda安装jupyer的时候报错: InvalidArchiveError(“Error with archive

摘要:本文针对Windows系统使用Conda时出现的InvalidArchiveError错误(文件路径过长或压缩包损坏),提供了解决方案。建议以管理员身份运行PowerShell并执行命令启用长路径支持(LongPathsEnabled),然后重启电脑或终端。作者通过该方法成功解决了jupyter安装问题。附有错误截图和解决后的成功截图。

猿小白的博客 783

【OS】AUTOSAR OS系统调用产生Trap的过程详解

AUTOSAR OS系统调用产生Trap的过程详解

qq_36056498的博客 2438

POJ 1088 滑雪(动态规划)(解题报告)

Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 1

CSUST_ACM的专栏 1243

Sigrity System Explorer ViaWizard模式进行过孔建模和仿真分析操作指导

点击TVac_lower tdvac_lower,自动跳转到2D时域曲线,查看最小低电平穿过VIL(ac)max电压的延时,结果如下。点击TVac_high tdvac_high,自动跳转到2D时域曲线,查看最小高电平穿过VIH(ac)min电压的延时,结果如下。点击max Vix_Rise,自动跳转到2D时域曲线,查看上升边PN交叉点与参考电压VREF(dc)的偏差,结果如下。Threshold:阈值,软件自带3个模板,default,Tr01,Tr02,本例选择Default。

weixin_54787054的博客 571

A.yuna学数论(解题报告)

Problem Description 在学习完各类算法之后,yuna决定开始学习数论了。yuna神当然从最简单的最小公倍数学起喽~~~~~ 定义 为1,2,…,n的最小公倍数,例如,B1 = 1,B2 = 2,B3 = 6,B4 = 12,B5 = 60,……。 yuna想知道对于给出的任意整数n,Bn是否等于Bn-1。yuna当然是知道答案的喽,但是她想考考rexdf,这次r

CSUST_ACM的专栏 1093

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

POJ 3528 Ultimate Weapon三维凸包(解题报告)

Description In year 2008 of the Cosmic Calendar, the Aliens send a huge armada towards the Earth seeking after conquest. The humans now depend on their ultimate weapon to retain their last hope

CSUST_ACM的专栏 921

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

POJ 1850 Code组合数学(解题报告)

Description Transmitting and memorizing information is a task that requires different coding systems for the best use of the available space. A well known system is that one where a number is assoc

CSUST_ACM的专栏 825

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

URAL 1348 Goat in the Garden 2计算几何(解题报告)

Description A goat is tied to a peg (in a point C) in a garden with a strong rope of the length L (i.e. a goat may eat a grass that is not farther than Lmeters from the peg). There is a bed of pi

CSUST_ACM的专栏 813

POJ 3219 Binomial Coefficients

Description The binomial coefficient C(n, k) has been extensively studied for its importance in combinatorics. Binomial coefficients can be recursively defined as follows: C(n, 0) = C(n, n

CSUST_ACM的专栏 791

URAL 1019 Line Painting(解题报告)

Description The segment of numerical axis from 0 to 109 is painted into white color. After that some parts of this segment are painted into black, then some into white again and so on. In total t

CSUST_ACM的专栏 781

ZOJ 1648 Circuit Board计算几何(解题报告)

Description On the circuit board, there are lots of circuit paths. We know the basic constrain is that no two path cross each other, for otherwise the board will be burned. Now given a circuit

CSUST_ACM的专栏 774

POJ 1862 Stripies(解题报告)

Description Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian – polosatiki, but the scientists had to invent an Englis

CSUST_ACM的专栏 711

HDU 1005 Number Sequence解题报告

Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n – 1) + B * f(n – 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n).  Input

CSUST_ACM的专栏 703

POJ 1654 Area计算几何(解题报告)

Description You are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate system. From this vertex, you may go step by step to

CSUST_ACM的专栏 702

POJ 2063 Investment(解题报告)

Description John never knew he had a grand-uncle, until he received the notary’s letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John

CSUST_ACM的专栏 699

ZOJ 1914 Arctic Network(解题报告)

Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication technologies are to be used in establishing the

CSUST_ACM的专栏 686

list

的底层是双向链表结构,双向链表中每个元素存储在互不相关的独立节点中,在节点中通过指针指向其前一个元素和后一个元素。,因此反向迭代器的实现可以借助正向迭代器,即:反向迭代器内部可以包含一个正向迭代器,对正向迭代器的接口进行包装即可。是可以在常数范围内在任意位置进行插入和删除的序列式容器,并且该容器可以前后双向迭代。迭代到该位置,在这段位置上迭代需要线性的时间开销;最大的缺陷是不支持任意位置的随机访问,比如:要访问。还需要一些额外的空间,以保存每个节点的相关联信息。个元素,必须从已知的位置。

xie0510_的博客 262
上一篇: POJ 1850 Code组合数学(解题报告)
下一篇: K次方(即求n^k的前三位与后三位)
CSUST_ACM
博客等级 码龄15年 42粉丝 127原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值