17 - 01 - 08 POJ 2060 (简单模拟)
来源:互联网 发布:2144剑雨江湖进阶数据 编辑:程序博客网 时间:2024/06/03 17:15
Taxi Cab Scheme
Time Limit: 1000MS Memory Limit: 30000KTotal Submissions: 6913 Accepted: 2843
Description
Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as possible,there is also a need to schedule all the taxi rides which have been booked in advance.Given a list of all booked taxi rides for the next day, you want to minimise the number of cabs needed to carry out all of the rides.
For the sake of simplicity, we model a city as a rectangular grid. An address in the city is denoted by two integers: the street and avenue number. The time needed to get from the address a, b to c, d by taxi is |a - c| + |b - d| minutes. A cab may carry out a booked ride if it is its first ride of the day, or if it can get to the source address of the new ride from its latest,at least one minute before the new ride's scheduled departure. Note that some rides may end after midnight.
For the sake of simplicity, we model a city as a rectangular grid. An address in the city is denoted by two integers: the street and avenue number. The time needed to get from the address a, b to c, d by taxi is |a - c| + |b - d| minutes. A cab may carry out a booked ride if it is its first ride of the day, or if it can get to the source address of the new ride from its latest,at least one minute before the new ride's scheduled departure. Note that some rides may end after midnight.
Input
On the first line of the input is a single positive integer N, telling the number of test scenarios to follow. Each scenario begins with a line containing an integer M, 0 < M < 500, being the number of booked taxi rides. The following M lines contain the rides. Each ride is described by a departure time on the format hh:mm (ranging from 00:00 to 23:59), two integers a b that are the coordinates of the source address and two integers c d that are the coordinates of the destination address. All coordinates are at least 0 and strictly smaller than 200. The booked rides in each scenario are sorted in order of increasing departure time.
Output
For each scenario, output one line containing the minimum number of cabs required to carry out all the booked taxi rides.
Sample Input
2208:00 10 11 9 1608:07 9 16 10 11208:00 10 11 9 1608:06 9 16 10 11
Sample Output
12
#include<iostream>#include<stdio.h>#include<cstring>int a[100][100],b[100],c[100];int main() {int,i,j,n,sum;while(scanf("%d",&n) && n!=0 ) {memset(b,0,sizeof(b));memset(c,0,sizeof(c));for(i=0; i<n; i++)for(j=0; j<n; j++)scanf("%d",&a[i][j]); //obtain maxtrixfor(i=0; i<n; i++)for(j=0; j<n; j++)b[i]+=a[i][j];//一行的和for(i=0; i<n; i++)for(j=0; j<n; j++)c[i]+=a[j][i];//一列的和int sum1=0,sum2=0,flag1,flag2;for(i=0; i<n; i++)if(b[i]%2) { //若和是奇数 sum1++; //sum>=2就无药可救了 flag1=i;}for(i=0; i<n; i++) {if(c[i]%2) { //若和是奇数 sum2++;flag2=i;}}if(sum1>1||sum2>1) printf("Corrupt\n");else if(sum1==0&&sum2==0)printf("OK\n");elseprintf("Change bit (%d,%d)\n",flag1+1,flag2+1);}return 0;}
1 0
- 17 - 01 - 08 POJ 2060 (简单模拟)
- POJ 2453 简单模拟
- POJ 2833 简单模拟
- poj 1573 简单模拟
- POJ 1013 (简单模拟)
- POJ 2996 简单模拟
- POJ 1886简单模拟
- POJ 3032 简单队列模拟
- POJ 1017Packets---简单模拟
- POJ 2497 Strategies 简单模拟
- poj 1281(简单模拟题)
- poj 1590Palindromes 简单模拟
- POJ 1017 Packets 简单模拟
- 17 - 01 - 09 POJ 1363 (栈模拟)
- POJ 3652 Persistent Bits 简单字符串模拟
- POJ 1573:Robot Motion:简单模拟
- poj 1281 MANAGER(简单模拟题)
- POJ 1132 Border(边界) 简单模拟
- 无法定位序数9828于动态链接库或者exe
- webpack babel 禁止编译 node_modules
- jmeter测接口基本测试流程
- 下拉刷新及上拉加载更多的ListView
- Struts2 3种动态方法调用方式
- 17 - 01 - 08 POJ 2060 (简单模拟)
- 4.UIButton
- SSH框架下过滤器设置解决润乾报表问题
- 线程编程之同步基础
- Android开发:仿微信和QQ空间发说说相册读取、拍照、图片裁剪和图片上传服务器等功能的实现
- php中的global变量为null
- Error:C:\Users\XX\.gradle\native\19\windows-amd64\native-platform.dll.lock (拒绝访问。)
- 树莓派连接多个wifi并上报IP地址
- 常用git命令