博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU-1050 Moving Tables
阅读量:6161 次
发布时间:2019-06-21

本文共 3506 字,大约阅读时间需要 11 分钟。

Moving Tables

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 11406    Accepted Submission(s): 3898

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 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. 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 N+3-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
1 /*  2 //代码一:   ---wrong answer(按照1051题的思路做的,但是不知道哪错了-------求指教)  3 #include
4 #include
5 using namespace std; 6 7 struct act 8 { 9 int s; 10 int t; 11 }a[201]; 12 bool visit[201]; 13 14 bool cmp(act k1,act k2) 15 { 16 return k1.s
t2) 33 { 34 t1^=t2; 35 t2^=t1; 36 t1^=t2; 37 } 38 a[i].s=t1; 39 a[i].t=t2; 40 } 41 sort(a,a+n,cmp); 42 memset(visit,false,sizeof(visit)); 43 st=0; 44 count=0; 45 visit[0]=true; 46 while(st
76 #include
77 int a[201]; 78 79 int main() 80 { 81 int T,s,t,j,max,n; 82 scanf("%d",&T); 83 while(T--) 84 { 85 max=0; 86 memset(a,0,sizeof(a)); 87 scanf("%d",&n); 88 while(n--) 89 { 90 scanf("%d%d",&s,&t); 91 if(s>t) 92 { 93 s^=t; 94 t^=s; 95 s^=t; 96 } 97 s=(s+1)/2; //很神奇的转化-----把对门的都变成一个编号,因为边界对门也不能重叠 98 t=(t+1)/2; 99 for(j=s;j<=t;j++)100 {101 ++a[j];102 if(a[j]>max)103 max=a[j];104 105 }106 }107 printf("%d\n",max*10);108 }109 return 0;110 }111

 

 

转载地址:http://gmefa.baihongyu.com/

你可能感兴趣的文章
P2P应用层组播
查看>>
Sharepoint学习笔记—修改SharePoint的Timeouts (Execution Timeout)
查看>>
CSS引入的方式有哪些? link和@import的区别?
查看>>
Redis 介绍2——常见基本类型
查看>>
asp.net开发mysql注意事项
查看>>
(转)Cortex-M3 (NXP LPC1788)之EEPROM存储器
查看>>
ubuntu set defult jdk
查看>>
[译]ECMAScript.next:TC39 2012年9月会议总结
查看>>
【Xcode】编辑与调试
查看>>
用tar和split将文件分包压缩
查看>>
[BTS] Could not find stored procedure 'mp_sap_check_tid'
查看>>
PLSQL DBMS_DDL.ALTER_COMPILE
查看>>
Activity生命周期
查看>>
高仿UC浏览器弹出菜单效果
查看>>
Ubuntu忘记密码,进不了系统的解决方法
查看>>
[原创]白盒测试技术思维导图
查看>>
<<Information Store and Management>> 读书笔记 之八
查看>>
Windows 8 开发之设置合约
查看>>
闲说HeartBeat心跳包和TCP协议的KeepAlive机制
查看>>
MoSQL
查看>>