HLG 1519 Tower Parking【模拟】

 

Description
There is a new revolution in the parking lot business: the parking tower. The concept is simple: you drive your car into the elevator at the entrance of the tower, 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 tower 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 tower 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 a conveyor belt one car in either direction takes 5 seconds.
Input
On the first line one positive number: the number of testcases, at most 100. After that per testcase:
• 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.
Output
Per testcase:
• One line with the number of seconds before the last customer is served.
Sample Input
2
1 5
-1 2 1 -1 3
3 6
-1 5 6 -1 -1 3
-1 -1 7 -1 2 9
-1 10 4 1 8 -1
Sample Output
25
320

题意:比较难懂...可以这样理解:有电梯和传送带从车场向外运车,每次传送带送到电梯口,传送带为环形(注意:可以顺时针和逆时针转)。

注意一下几点:车按照1 2 3 ....n的顺序运出;不同层之间没有任何影响;电梯和传送带之间不是同时工作;电梯口的位置是上一次车走的位置;

代码如下:

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std; 
struct park
{
    int x, y;
}; 
int main()
{
    int i, j, n, m, T, k, t;
    scanf("%d", &T);
    while(T--)
    {
        scanf("%d%d", &n, &m);
        park p[2505]; 
        int turn[55];
        memset(turn, 0, sizeof(turn)); 
        int num=0; 
        for(i=1; i<=n; i++)
        { 
            turn[i]=1; 
            for(j=1; j<=m; j++)
            {
                scanf("%d", &k);
                if(k==-1) 
                    continue;
                num++;
                p[k].x=i, p[k].y=j;
            }
        } 
        int total=0; 
        int mid; 
        for(i=1; i<=num; i++)
        {
            if(p[i].y>turn[p[i].x])
                 mid=p[i].y-turn[p[i].x];
            else
                mid=turn[p[i].x]-p[i].y; 
            total+=20*(p[i].x-1)+5*(min(mid, m-mid));
            turn[p[i].x]=p[i].y;
        }
        printf("%d\n", total);
    }
}    

转载于:https://www.cnblogs.com/Hilda/archive/2012/08/06/2624438.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用:OpenCvSharp是一个OpenCV的.Net wrapper,用于开发基于OpenCV的应用程序,它与原始的OpenCV更接近,并提供了详细的使用样例。 引用:对于使用OpenCV进行图像处理的代码示例,可以使用import numpy as np import cv2来导入OpenCV库,并使用cv2.imread、cv2.imshow等函数进行图像的读取和显示。 引用:如果想要使用OpenCV进行分类器的生成,可以使用opencv_traincascade.exe命令,并提供指定的参数,例如-data用于指定生成的分类器的保存路径,-vec用于指定正样本描述文件的路径,-bg用于指定负样本文件的路径,以及其他参数如numPos、numNeg、minHitRate等。 关于"opencv hlg"的问题,根据提供的引用内容,我没有找到与"opencv hlg"相关的具体信息。可能需要提供更多背景或上下文信息来解答该问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [OpenCvSharp](https://download.csdn.net/download/qq_18865111/86722032)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [python opencv 读取图片 存储图片](https://blog.csdn.net/weixin_41799483/article/details/80829825)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [opencv分类器训练方法](https://blog.csdn.net/weixin_41799483/article/details/80567909)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值