title: Intelligent Parking Building 河南省第十届省赛

tags: [模拟,省赛]

题目描述:

There is a new revolution in the parking lot business: the parking  building. The concept is simple: you drive your car into the elevator at the entrance of the building, and the elevator and conveyor belts drag the car to an empty parking spot, where the car remains until you pick it up. When you return, the elevator and conveyor belts move your car back to the entrance and you’re done.

The layout of the building is simple. There is one central elevator that transports the cars between the different floors. On each floor there is one giant circular conveyor belt on which the cars stand. This belt can move in clockwise and counterclockwise direction. When the elevator arrives on a floor, it becomes part of the belt so that cars can move through it.

At the end of the day the building is usually packed with cars and a lot of people come to pick them up. Customers are processed in a first come first serve order: the elevator is moved to the floor of the first car, the conveyor belt moves the car on the elevator, the elevator is moved down again, and so on. We like to know how long it takes before the last customer gets his car. Moving the elevator one floor up- or downwards takes 10 seconds and moving  the conveyor belt one position in either direction takes 5 seconds.

输入:

On the first line one positive number: the number of testcases, at most 30.  Each test case specifies:

  • One line with two integers h and l with 1 ≤ h ≤ 50 and 2 ≤ l ≤ 50: the height of the parking tower and the length of the conveyor belts.
  • h lines with l integers: the initial placement of the cars. The jth number on the ith line describes the jth position on the ith floor. This number is −1 if the position is empty, and r if the position is occupied by the rth car to pick up. The positive numbers form a consecutive sequence from 1 to the number of cars. The entrance is on the first floor and the elevator (which is initially empty) is in the first position. There is at least one car in the parking tower.

输出:

For each test case generate a single line containing a single integer  that is the number of seconds before the last customer is served.

样例输入:

3
1 5
1 -1 -1 -1 2
1 5
2 -1 -1 -1 1
3 6
-1 5 6 -1 -1 3
-1 -1 7 -1 2 9
-1 10 4 1 8 -1

样例输出:

5
10
320

分析:

表示英语不好的人伤不起,题意都是读了好久才读出来的,心累~~~~

OK,言归正传:

有一个地下车库,车库的高度为h,每层的车库中都有L个停车位,这L个停车位相当于是一个环形的传送带,传送带上有L个位置,每个位置上都可以停一辆车(相当于L个停车位)。有二维数组来表示当前楼层某个停车位上的停车信息,为-1的话意味着这个车位是空的,其余的数字依次表示车主提车的先后顺序(注意提车的时候肯定只能一辆一辆的提)。

让求得就是最后一位车主需要多久的时间才能够提到车,电梯上或者下一层所需10个单位时间,传送带转动一个车位需要5个单位时间,当然传送带可以正转也可以逆转。

首先肯定的是只能够一辆车一辆车的提,不能够在提一辆车的过程中顺便把下一辆车也提出去,这是不符合实际情况也不符合题意。然后就是关于传送带的位置问题(这里所说的位置都是传送带在楼梯口的那个位置,最开始的时候每一层都是一号位置),原先我就一直以为的是传送带在把车送到楼梯口后,就又回到原来的位置了,然后才意识到自己考虑的多了,传送带在把一辆车送到电梯口之后,传送带就不再动了,当前位置就是下一次的传送带的位置。

代码:

#include<stdio.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
struct Node
{
int floor;///楼层
int num;///停车位
} node[2509];
int main()
{
int T,n,m,Max;
scanf("%d",&T);
while(T--)
{
Max=-1;
memset(node,NULL,sizeof(node));///结构体整体初始化
int Tu[52][52];
scanf("%d%d",&n,&m);
for(int i=1; i<=n; i++)
{
Tu[i][0] = 1;///每一层最开始的时候传送带的位置都是1
for(int j=1; j<=m; j++)
{
scanf("%d",&Tu[i][j]);
if(Tu[i][j]!=-1)
{
if(Tu[i][j]>Max)///max表示的是最多有多少辆车需要提出去
Max=Tu[i][j];
node[Tu[i][j]].floor=i;///楼层赋值
node[Tu[i][j]].num=j;///停车位赋值
}
}
}
int sum=0,flag;
for(int i=1; i<=Max; i++)
{
sum+=(node[i].floor-1)*10*2;///每次提车的过程都相当于从一楼到停车楼层,在送回一楼,则电梯的时间加倍
int mm = min(abs(node[i].num - Tu[node[i].floor][0]),m- abs(node[i].num - Tu[node[i].floor][0]));
///在同行中,找距离左右两边最近的那个。
sum += mm * 5;
Tu[node[i].floor][0]=node[i].num;///传送带的位置有记忆功能
}
printf("%d\n",sum);
}
return 0;
}

河南省第十届省赛 Intelligent Parking Building的更多相关文章

  1. 河南省第十届省赛 Plumbing the depth of lake (模拟)

    title: Plumbing the depth of lake 河南省第十届省赛 题目描述: There is a mysterious lake in the north of Tibet. A ...

  2. 河南省第十届省赛 Binary to Prime

    题目描述: To facilitate the analysis of  a DNA sequence,  a DNA sequence is represented by a binary  num ...

  3. 四川第十届省赛 A.Angel Beats bitset

    四川第十届省赛 A.Angel Beats bitset 题目链接 题解参考:http://www.cnblogs.com/Aragaki/p/9142250.html 考虑用bitset来维护对于所 ...

  4. 每天一套题打卡|河南省第十届ACM/ICPC

    A.谍报分析 题意:请你编程,快速统计出频率高的前十个单词. 思路:字符串输入,map哈希表map<string,int >记录每个单词出现的次数,pair重载优先级 #include&l ...

  5. 河南省acm第九届省赛--《表达式求值》--栈和后缀表达式的变形--手速题

    表达式求值 时间限制:1000 ms | 内存限制:65535 KB 难度:3   描述 假设表达式定义为:1. 一个十进制的正整数 X 是一个表达式.2. 如果 X 和 Y 是 表达式,则 X+Y, ...

  6. 【河南省第十届ACM 省赛 A-谍报分析】

    题目描述 “八一三”淞沪抗战爆发后,*几次准备去上海前线视察和指挥作战.但都因为宁沪之间的铁路和公路遭到了敌军的严密封锁,狂轰滥炸,一直未能成行. 特科组织,其主要任务是保卫的安全,了解和掌握敌方的动 ...

  7. CSU 1511 残缺的棋盘 第十届湖南省赛题

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511 题目大意:在一个8*8的棋盘中,给你一个起点位置和一个终点位置,同时也给你一个陷阱 ...

  8. CSU 1507 超大型LED显示屏 第十届湖南省赛题

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1507 解题思路:这是一道模拟题,看了那么多人的代码,我觉得我的代码是最简的,哈哈,其实就 ...

  9. 福州大学第十届校赛 & fzu 2128最长子串

    思路: 对于每个子串,求出 母串中 所有该子串 的 开始和结束位置,保存在 mark数组中,求完所有子串后,对mark数组按 结束位置排序,然后 用后一个的结束位置 减去 前一个的 开始 位置 再 减 ...

随机推荐

  1. Django笔记 —— 模板高级进阶

    最近在学习Django,打算玩玩网页后台方面的东西,因为一直很好奇但却没怎么接触过.Django对我来说是一个全新的内容,思路想来也是全新的,或许并不能写得很明白,所以大家就凑合着看吧- 本篇笔记(其 ...

  2. ASP.NET Web API 2 返回 Json格式

    最近在学习ASP.NET的Web API,刚刚开始以为会有些复杂,结果却非常简单. 学习的地址:http://www.asp.net/web-api/overview/getting-started- ...

  3. Sqlite Datetime类型详解

    日期和时间函数 date(timestring, modifier, modifier, ...) time(timestring, modifier, modifier, ...) datetime ...

  4. extjs/js时间校验

    //时间秒判断var re=/^(?:19|20)[0-9][0-9]-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:[0-2][1-9])|(?:[1-3][0-1])) (?:( ...

  5. HDFS分布式集群

    一.HDFS伪分布式环境搭建 Hadoop分布式文件系统(HDFS)被设计成适合运行在通用硬件(commodity hardware)上的分布式文件系统.它和现有的分布式文件系统有很多共同点.但同时, ...

  6. 问题 C: 质因数的个数

    1947: 质因数的个数 时间限制: 1 Sec  内存限制: 32 MB提交: 245  解决: 114[提交][状态][讨论版][命题人:外部导入] 题目描述 求正整数N(N>1)的质因数的 ...

  7. 目标检测之Faster-RCNN的pytorch代码详解(模型训练篇)

    本文所用代码gayhub的地址:https://github.com/chenyuntc/simple-faster-rcnn-pytorch  (非本人所写,博文只是解释代码) 好长时间没有发博客了 ...

  8. windows2008 R2 系统 安装wampserver提示“缺少msvcr110.dll文件”处理办法

    windows2008 R2 系统 安装wampserver提示“缺少msvcr110.dll文件”处理办法 原因分析: 因缺少Visual C++ Redistributable for Visua ...

  9. io学习2-磁盘阵列RAID

    磁盘阵列 RAID(Redundant ArrayOf Inexpensive Disks) 如果你是一位数据库管理员或者经常接触服务器,那对RAID应该很熟悉了,作为最廉价的存储解决方案,RAID早 ...

  10. PAT 1089 狼人杀-简单版

    https://pintia.cn/problem-sets/994805260223102976/problems/1038429385296453632 以下文字摘自<灵机一动·好玩的数学& ...