博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj1548--Robots
阅读量:6824 次
发布时间:2019-06-26

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

Robots
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4037   Accepted: 1845

Description

Your company provides robots that can be used to pick up litter from fields after sporting events and concerts. Before robots are assigned to a job, an aerial photograph of the field is marked with a grid. Each location in the grid that contains garbage is marked. All robots begin in the Northwest corner and end their movement in the Southeast corner. A robot can only move in two directions, either to the East or South. Upon entering a cell that contains garbage, the robot will pick it up before proceeding. Once a robot reaches its destination at the Southeast corner it cannot be repositioned or reused. Since your expenses are directly proportional to the number of robots used for a particular job, you are interested in finding the minimum number of robots that can clean a given field. For example, consider the field map shown in Figure 1 with rows and columns numbered as shown and garbage locations marked with a 'G'. In this scheme, all robots will begin in location 1,1 and end in location 6, 7. 
 
Figure 1 - A Field Map
Figure 2 below shows two possible solutions, the second of which is preferable since it uses two robots rather than three. 
 
Figure 2 - Two Possible Solutions
Your task is to create a program that will determine the minimum number of robots needed to pick up all the garbage from a field. 

Input

The input consists of one or more field maps followed by a line containing -1 -1 to signal the end of the input data. A field map consists of one or more lines, each containing one garbage location, followed by a line containing 0 0 to signal the end of the map. Each garbage location consists of two integers, the row and column, separated by a single space. The rows and columns are numbered as shown in Figure 1. The garbage locations will be given in row-major order. No single field map will have more than 24 rows and 24 columns. The sample input below shows an input file with two field maps. The first is the field map from Figure 1.

Output

The output will consist of a single line for each field map containing the minimum number of robots needed to clean the corresponding field.

Sample Input

1 21 42 42 64 44 76 60 01 12 24 40 0-1 -1

 

Sample Output

21

 

Source

//主要找出关键意思;本题只要满足存在最少多少个划分使得每个划分里面的二元组都满足x1 <= x2并且y1 <= y2 即可:Dirworth定理
1 #include 
2 #include
3 using namespace std ; 4 5 struct field 6 { 7 int h ; 8 int z ; 9 } ;10 field num[600] ;11 12 bool cmp(field h,field z) /*13 {14 if(h.h == z.h)15 return h.z < z.z ;16 else17 return h.h < z.h ; /*18 }19 20 21 int main()22 {23 int m,n,i ;24 while(~scanf("%d %d",&num[0].h, &num[0].z) , (num[0].h!=-1 , num[0].z!=-1))25 {26 for(i=1; ;i++)27 {28 scanf("%d %d",&num[i].h, &num[i].z) ;29 if(!num[i].h , !num[i].z)30 break;31 }32 sort(num, num+i, cmp) ;33 int temp, j, k, total=0 ;34 for(j=0; j
= temp)43 {44 temp=num[k].z ;45 num[k].z = 0 ;46 }47 }48 }49 50 } /*51 printf("%d\n",total);52 }53 return 0 ;54 }

 

转载于:https://www.cnblogs.com/soTired/p/4623586.html

你可能感兴趣的文章
flexPaper +swftools实现文档在线阅读
查看>>
分形树的绘制
查看>>
loadrunner请求中有汉字 如何编码
查看>>
java数据结构 • 面向对象 • 异常 • 随机数·时间
查看>>
springmvc 实现pc端手机端适配(同一个请求根据不同客户端展示不同界面)
查看>>
BTree和B+Tree详解
查看>>
VS2005工程迁移到Eclipse CDT
查看>>
Linux高端内存映射(上)【转】
查看>>
usb_control_msg参数详解【转】
查看>>
8086汇编指令速查手册
查看>>
j2EE web.xml中的url-pattern的映射规则
查看>>
带输入输出参数的存储过程
查看>>
字符编码简介
查看>>
LevelDB源码之六缓存机制
查看>>
双向链表
查看>>
安装unity3d多个版本共存
查看>>
如何获取模拟器安装的app的位置
查看>>
[LeetCode] Largest Rectangle in Histogram 解题报告
查看>>
未能加载文件或程序集Newtonsoft.Json, Version=4.5.0.0
查看>>
国外服务器鸟文windows,时间12小时制,如何改成24小时呢?我来告诉你
查看>>