Intelligent Parking Building
来源:互联网 发布:树状结构软件 编辑:程序博客网 时间:2024/06/08 10:13
题目描述
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.
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.
•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.
样例输入
31 51 -1 -1 -1 21 52 -1 -1 -1 13 6-1 5 6 -1 -1 3-1 -1 7 -1 2 9-1 10 4 1 8 -1
样例输出
510320
提示
来源
河南省第十届大学生程序设计竞赛
水题,模拟题,但题意真难懂
装置如图所示,模拟让车从出口(与电梯相连)出去
代码如下:
#include<iostream>#include<stdio.h>#include<string.h>#include<cmath>#include<cmath>#include<set>using namespace std;const int N=260;struct Fuck{ int x,y;}a[N];int b[56];//每层电梯所对车位的编号int main(){ int n,h,l,maxx; while(cin>>n) { while(n--) { memset(b,0,sizeof(b));//初始车位编号是0的与电梯相邻 scanf("%d%d",&h,&l); maxx=0; for(int i=0;i<h;i++) for(int j=0;j<l;j++) { int m; cin>>m; if(m!=-1) { a[m].x=i; a[m].y=j; maxx=max(maxx,m); } } int ant=0; for(int i=1;i<=maxx;i++)//模拟一个一个出 { int cen=a[i].x;//i的所在的层数 int num=a[i].y;//所在的编号 ant+=2*cen*10; ant+=5*min(fabs(num-b[cen]),l-fabs(num-b[cen]));//逆时针 顺时针 b[cen]=num; } cout<<ant<<endl; } } return 0;}
阅读全文
0 0
- Intelligent Parking Building
- Intelligent Parking Building
- 问题 H: Intelligent Parking Building
- 第十届省赛-H-Intelligent Parking Building
- 2017年河南省ACM省赛 Problem H: Intelligent Parking Building
- H Intelligent Parking Building 河南第十届ACM真题 【模拟】
- 河南省第十届ACM省赛题目:问题 H: Intelligent Parking Building
- Building Intelligent .NET Applications : Agents, Data Mining, Rule-Based Systems, and Speech Process
- 《Parking system》
- zoj2878------------------Parking
- 11364 - Parking
- Optimal Parking
- Optimal Parking
- Optimal Parking
- Parking lot
- Optimal Parking
- Intelligent people
- Intelligent IME
- CodeForces 55 C.Pie or die(博弈论)
- 状态模式
- 轻松理解 Android Binder,只需要读这一篇
- UVA 1449 Dominating Patterns(AC自动机)
- lower_bound()返回值
- Intelligent Parking Building
- 周记(中)
- 5.Algorithm Gossip: 老鼠走迷官(一)
- CSDN-20170831
- iOS第三方类库IIViewDeck使用方法
- redis参数配置
- scala执行外部命令
- 修改caffe源代码--添加loss(层)函数--GPU
- 事务补偿型TCC事务