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;///每一层最开始的时候传送带的位置都是1for(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;
}

转载于:https://www.cnblogs.com/cmmdc/p/6887779.html

河南省第十届省赛 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. 河南省第十届ACM赛题

    本届赛题难度不是太大,9道题目我们队一共做了7道拿了个银,很遗憾没有能为我们学校带来首金. 贴上我们队的ac的代码留个纪念,题目我就不一个一个字码出来了,直接上照片,没做的题我就不在贴了... A题: ...

  3. 科林明伦杯哈理工第十届同步赛部分题解

    科林明伦杯哈理工第十届同步赛部分题解 B题 搭积木问题 F题 三角形 B题 搭积木问题 链接:https://ac.nowcoder.com/acm/contest/5758/B 来源:牛客网 题目描 ...

  4. 蓝桥杯嵌入式第十届省赛真题

    蓝桥杯嵌入式第十届省赛真题 文章目录 蓝桥杯嵌入式第十届省赛真题 1.题目分析 2.项目结构 2.1数组思路 2.2Key_Flag控制对应逻辑 2.3KEY控制操作 1.题目分析 总的来说这题考点特 ...

  5. 蓝桥杯单片机第十届国赛练习

    单片机型号:IAP15F2K60S2. 蓝桥杯第十届国赛有串口,本文着手进行一番练习, 文末会附上整个工程下载地址. 这一届赛题的练习对我来说还是有些难度 我看题后做了以下几个设计方面的点总结列举: ...

  6. 突击蓝桥杯嵌入式(六)——第十届省赛真题

    突击蓝桥杯嵌入式(六)--第十届省赛真题 一.题干 二.题目分析 考点1.ADC(没啥好说的) 占用引脚PB15(R37) 考点2:按键4个(PB0,PB1,PB2,PA0) 考点3:LCD,高亮 考 ...

  7. 河南省第十届大学生程序设计竞赛 A,B,C,D,F,G,H 题解

    H: Intelligent Parking Building 时间限制: 1 Sec  内存限制: 128 MB 提交: 22  解决: 20 [提交][状态][讨论版] 题目描述 There is ...

  8. Intelligent Parking Building

    Intelligent Parking Building 题目描述 There is a new revolution in the parking lot business: the parking ...

  9. [蓝桥杯]2019年第十届省赛真题C/C++ B组 填空+大题

    第十届蓝桥杯省赛题目 填空A:组队 填空B:年号字串 填空C:数列求值 填空 D: 数的分解 填空 E: 迷宫 大题F:特别数的和 大题G:完全二叉树的权值 大题H:等差数列 大题I-后缀表达式 填空 ...

最新文章

  1. usaco ★Humble Numbers 丑数
  2. linux 空文件 sed 不能写入数据
  3. Jmeter使用基础笔记-写一个http请求
  4. 埋点全解 2:iOS 应用程序状态
  5. Arista与思科新一轮交锋,Arista略胜一筹
  6. Django-请求与响应
  7. 边工作边刷题:70天一遍leetcode: day 92
  8. ES6, Angular,React和ABAP中的String Template(字符串模板)
  9. 『设计模式』备忘录模式(memento)下象棋,我就想悔棋怎么办
  10. python全局变量global线程安全_对python多线程与global变量详解
  11. [Linux]变量加减赋值以及将String转int
  12. 你以为用了 BigDecimal 后,计算结果就一定精确了?
  13. JS:关于JS字面量及其容易忽略的12个小问题
  14. Go 网络 TCP Client (一)
  15. ASO优化:App从0到1进行ASO优化
  16. 编写函数,求字符串的长度
  17. mysql 一张表连两次_MySQL查询两次和双表联查哪个效率高
  18. 管制条目的地DDS文件生成器,ATC3版
  19. oracle 学号为主键,oracle上机练习1
  20. 任务栏微信图标显示为白框,解决办法

热门文章

  1. 【MTK】user版本下输出aee db 和 anr trace
  2. 虚拟机开机报错:“Could not initialize plugin ‘/usr/lib64/vmware/plugin/libnvidia-vgx.so‘ for vGPU “
  3. C语言指针【常见类型】
  4. 作业出现Amazon S3; Status Code: 503错误分析
  5. 【软考中级】网络工程师怎么复习?
  6. 基于python的火车票订票系统的设计与实现_火车票订票系统的开发与设计
  7. 全球及中国铁路运输行业建设形势分析与发展趋势预测报告2022版
  8. 【STM32cubeMX+HAL库】US100超声波模块原理篇
  9. 2018.1.素数又称质数,是指大于1的自然数,且除了1和它本身除外不再有其他因子。输入两个正整数a和b,输出a与b之间的全部素数,每5个素数换一行,假设2<=a<=b.
  10. 求教专业人士,视频的码率多少合适?是不是和分辨率、帧率有关?