POJ 1083 Moving Tables

POJ1083-Moving Tables 北大POJ1083-Moving Tables 解题报告+AC代码 立即下载

The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.

在这里插入图片描述
The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan to reform its system. The reform includes moving a lot of tables between rooms. Because the corridor is narrow and all the tables are big, only one table can pass through the corridor. Some plan is needed to make the moving efficient. The manager figured out the following plan: Moving a table from a room to another room can be done within 10 minutes. When moving a table from room i to room j, the part of the corridor between the front of room i and the front of room j is used. So, during each 10 minutes, several moving between two rooms not sharing the same part of the corridor will be done simultaneously. To make it clear the manager illustrated the possible cases and impossible cases of simultaneous moving.
在这里插入图片描述

For each room, at most one table will be either moved in or moved out. Now, the manager seeks out a method to minimize the time to move all the tables. Your job is to write a program to solve the manager’s problem.

Input

The input consists of T test cases. The number of test cases ) (T is given in the first line of the input file. Each test case begins with a line containing an integer N , 1 <= N <= 200, that represents the number of tables to move.
Each of the following N lines contains two positive integers s and t, representing that a table is to move from room number s to room number t each room number appears at most once in the N lines). From the 3 + N -rd
line, the remaining test cases are listed in the same manner as above.

Output

The output should contain the minimum time in minutes to complete the moving, one per line.

Sample Input

3 
4 
10 20 
30 40 
50 60 
70 80 
2 
1 3 
2 200 
3 
10 100 
20 80 
30 50 

Sample Output

10
20
30

题意描述:

给出n对房间号,然后让你从第一个房间里边移动一张桌子,移到第二个房间里边,无论多远10分钟之内都可以完成,但是走廊每次只能移动一张,问n对全不完成,需要多长时间。

解题思路:

由题的图一可以看出来,它是单号一边双号一边,因此需要判断初始和结束房间的单双号,(假设从2号移到5号,因为2号在移动的时候1号也被占用,同理移到5号时6号也被占用了。)用一个数组标记之后找出最大的层数10就可以了。

AC代码:

#include<stdio.h>
#include<string.h>
int main(void)
{
	int t,n,count,s,t1,book[410],max,z,temp;
	scanf("%d",&t);
	while(t--){
		count=1;
		z=-1;max=-1;
		memset(book,0,sizeof(book));
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d%d",&s,&t1);
			if(s>t1){
				temp=s;
				s=t1;
				t1=temp;
			}
			if(s%2==0)
				s--;
			if(t1%2!=0)
				t1++;
			for(int j=s;j<=t1;j++)
				book[j]++;
		}
		for(int k=1;k<=400;k++)
			if(max<book[k])
				max=book[k];
		printf("%d\n",max*10);	
	}
	return 0;
}
acm程序例题2道,还有一道思考的题目(第四题) 这个是对于一道acm程序设计中的一道题,同时在解题同时还引出了第四题 立即下载

相关推荐

飞行器坐标转换

本文定义的是右手直角坐标系,x−y−zx-y-zx−y−z轴分别为北-天-东。从AAA坐标系到BBB坐标系是分别绕y−z−xy-z-xy−z−x轴,即天-东-北旋转ψ−θ−γψ−θ−γ。如果AAA是惯性系,BBB是机体系,则这三个角度分别为偏航角、俯仰角、横滚角。图1 惯性系到机体系。

gongfuyd的博客 1355

搬桌子问题

The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. r has 200 rooms each on the north side and south side along the corridor. Rece...

qq_43628925的博客 1064

nmap、X-Scan漏洞扫描和Metasploit中用永恒之蓝漏洞入侵靶机并上传冰河

利用nmap、X-Scan扫描靶机的漏洞,在Metasploit中用扫描出的永恒之蓝漏洞入侵靶机,建立连接后上传冰河木马控制靶机,最后用冰河陷阱清除靶机的冰河木马,记一次完整的入侵控制实验。

m0_59302403的博客 4408

HDU1050 Moving Tables

  Moving TablesTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1715    Accepted Submission(s): 663Problem DescriptionThe famous ACM (Advan

Adam·Niuen 3130

TortoiseSVN的安装与使用

TortoiseSVN的安装与应用1、安装1.1、下载TortoiseSVN    点击下载TortoiseSvn1.2、下载汉化包。上面的页面中,找到Chinese, simplified汉化包,点击32位或者64位的Setup,下载汉化包。1.3、安装TortoiseSVN。在选择安装路径页面时要记得勾选“command line client tools”,默认不是勾选的。这里不勾选的话在I...

qq_28566071的博客 4万+

Linear超高PSRR线性稳压器-典型应用电路解析

本文整理完了LT3045数据手册内所有的典型应用电路,试图让沉默的电路开口,简单介绍了他们这样做的目的和原理,从中我们可以更加熟悉这颗经典芯片的应用。但也有一些电路并没有搞懂,遗留下了不少问题。

硬件工程师笔记 2943

每周一题2_杭电ACM_Moving Tables

Moving Tables 题目来源:杭电ACM 1.3.1 原题描述 Problem Description · The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north side and south side along the

童话与梦的博客 691

第三方系统(异构系统)基于token身份认证方式访问Ecology9的Restful接口Ecology9服务器配置部分

通过Token的认证方式调用Ecology9系统Restful业务接口服务器配置部分

svsou的专栏 2176

HDU_1050 重叠数

先将数组进行排序,第一次循环,将不重叠的元素从数组中删除(这里将flag赋值为false),sum+=10继续第二次循环,以此类推,直到数组中没有元素(flag全为false)#include #include #include using namespace std; struct move{ public: int start; int end; bool flag; }; bool comp( move p, move q){ return p.s

格物致知 941

PyCharm高效配置Gitee全攻略

本文介绍了如何在PyCharm和VS Code中配置Gitee插件并管理代码。主要内容包括:1) PyCharm连接Gitee的配置步骤;2) 代码拉取与冲突解决方法;3) VS Code界面功能区域详解;4) 完整的代码提交流程(暂存→提交→推送)。特别说明了VS Code中Git面板的使用方法,以及推送代码到Gitee远程仓库的具体操作步骤。文章还提供了解决代码冲突的建议和注意事项,帮助开发者更好地进行版本控制。

ZhangJiqun&191cm&85kg 302

AI自动化时代:一人公司的崛起与商业机会

AI技术正在重塑商业格局,催生"一人公司"创业新模式。这种轻资产、高效率的商业模式通过AI自动化运营,让个人创业者能以极低成本挑战传统企业。核心机会包括:1)AI自主公司替代人力密集型业务;2)为企业提供AI转型解决方案;3)利用AI工具实现个人创业。创业者需快速验证创意,聚焦人机协作,把握当前AI发展窗口期。未来,AI赋能的"一人公司"将成为商业新常态,带来更高的专业化和灵活性。抓住AI红利,学会人机协作,是个人创业成功的关键。

这里汇聚了前沿的技术分享与实用的开发技巧,带你探索从创意到企业的技术创业之路。 520

SDAU 贪心专题 00 搬桌子

1:问题描述Problem DescriptionThe famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and sout

ww的博客 563

管理类联考——逻辑——真题篇——按知识分类——综合推理

29、某部门抽检了肉制品、白酒、乳制品、干果、蔬菜、水产品、饮料等﹖类商品共521种样品,发现其中合格样品515种,不合格样品6种。已知: (1)蔬菜、白酒中有2种不合格样品。 (2)肉制品、白酒、蔬菜、水产品中有5种不合格样品。 (3)蔬菜、乳制品、干果中有3种不合格样品。 根据上述信息,可以得出以下哪项? A. 乳制品中没有不合格样品。 B. 肉制品中没有不合格样品。 C. 蔬菜中没有不合格样品。 D. 白酒中没有不合格样品。 E. 水产品中没有不合格样品。 31~32题基于以下题干: 某中学举行田径运

stqer的博客 2023

POJ1083 Moving Tables

POJ1083 Moving Tables Time Limit:1000MS Memory Limit:10000K Total Submissions:35297 Accepted:11774 Description The famous ACM (Advanced Computer Maker) Company has ...

weixin_30760895的博客 156

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

POJ 1083 Moving Tables

POJ 1083 Moving Tables The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north side and sout...

不屈不挠的拉普 287

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

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

POJ 1083 Moving Tables 已被翻译

woniupengpeng的专栏 380

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

POJ 刷题系列:1083. Moving Tables

POJ 刷题系列:1083. Moving Tables传送门:POJ 1083. Moving Tables题意: 一条走廊,两栏房间。搬运工每次从房价i移动到房间j需要10分钟,给定一系列的移动路线 i -> j,问最少需要多少时间。 思路: 实际上是求解多个区间中重叠区间的最大个数。采用imos累积,很好的一个思路。先对每个区间的起点和终点求偏导,然后再累积,累积数组中的最大值即

Demon-初来驾到 747

poj1083 Moving Tables

链接:http://poj.org/problem?id=1083 好早的一个题,大一的时候做过一次。当然没做出来。今天又拿出来做了。 discuss中很多说贪心过不了,但我还是看到有个别人用贪心过的。所以,我也是坚持要用贪心写。 有些个地方要注意: 1)s、t大小未知,所以必要时要对其进行交换 2)对房间号做处理: s=(s+1)/2; t=(t+1)/2; 3)对s进行排序(在

u012914220的专栏 1124

POJ 1083 Moving Tables 贪心

题目来源:http://poj.org/problem?id=1083 题意:就是在房间之间移动桌子,当移动两个桌子时,这两个房间之间的走廊是满的,即其他的移动不能占用该段空间。求最少移动时间。 思路:按左端点排序,之后两重循环即可。需要注意的地方,左端点不一定比右端点大,因此需要处理一下。 代码: #include #include #include #include using

1081

【poj刷题记录】1083:Moving Tables

培养信心练手题,POJ1083题目描述如下: 这题的思路就是把房号转化为走廊编号(偶数房号除以2得到对应走廊编号,奇数房号加一除以二的打斗对应走廊编号),然后对个编号的走廊被走过的次数进行统计,整条走廊中走过次数最高的一段的次数即为最少搬运趟数。需要注意的是这道题的输入房号可能是先大后小,需要处理一下,不然就会陷入绝望WA中ORZ(别问我为什么知道),具体代码如下: #include <...

qq_38331950的博客 382

POJ - 1083 Moving Tables

//poj 1083 // [6/11/2014 wind] #include #include #include #include using namespace std; const int MAX_N = 200; int n; int cdr1[MAX_N], cdr2[MAX_N]; int cnt[MAX_N]; void solve() { memset ( cnt,

NightWind 734

POJ1083 Moving Tables(思维详解)

POJ 1083http://poj.org/problem?id=1083 题目大意: 题目很长,大致意思是有400个面对面的房间,现在要从一个房间到另一个房间移动物品 ,每次花费10分钟,但是移动过程中所有的经过的走廊都会被占用,也就是不能使用,问最少移动完所有的物品需要多久。 解题思路: 由于每次移动过程中都会占用相关的走廊,因此我们只需要枚举每个房间前的走廊需要被...

Sensente的博客 472

POJ 1083 Moving Tables 题解

POJ 1083题解

DarkoDu的博客 733

poj 1083 Moving Tables

模拟题,用到了编程之美中的思想---高效率地安排见面会 其实这个搬桌子是一样的,占用过道,那么核心思想就是把过道看成那个题目里面的时间轴 那么思想就是找到这个时间轴上的某一个时间点,使包括这个时间点的时间区间个数最多,那么这个个数乘以十就是我们要求的搬桌子的时间 代码的核心思想: 把所有的B[i],E[i]按大小排序,然后遍历这个统一的数组,如果遇到一个B[i],就把当前的时间数加

qwerty_xk的专栏 1549
上一篇: POJ 3641 Pseudoprime numbers
下一篇: POJ 3050 Hopscotch(dfs暴力)
鳳九~
博客等级 码龄8年 1384粉丝 215原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值