C.Distribution Center---(dp)2016筑波区域赛

本文介绍了一种关于机器人臂调度的问题解决方法,通过合理安排机器人臂的位置来实现不同生产线产品向仓储室的有效混合分配。利用机器人臂特性,确保每个仓储室能接收尽可能多的产品种类。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Distribution Center

题目链接http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=2293

Description

The factory of the Impractically Complicated Products Corporation has many manufacturing lines and the same number of corresponding storage rooms. The same number of conveyor lanes are laid out in parallel to transfer goods from manufacturing lines directly to the corresponding storage rooms. Now, they plan to install a number of robot arms here and there between pairs of adjacent conveyor lanes so that goods in one of the lanes can be picked up and released down on the other, and also in the opposite way. This should allow mixing up goods from different manufacturing lines to the storage rooms. Depending on the positions of robot arms, the goods from each of the manufacturing lines can only be delivered to some of the storage rooms. Your task is to find the number of manufacturing lines from which goods can be transferred to each of the storage rooms, given the number of conveyor lanes and positions of robot arms

Input

The input consists of a single test case, formatted as follows.
n m
x1 y1
.
.
.
xm ym
An integer n (2 ≤ n ≤ 200000) in the first line is the number of conveyor lanes. The lanes are numbered from 1 to n, and two lanes with their numbers differing with 1 are adjacent. All of them start from the position x = 0 and end at x = 100000. The other integer m (1 ≤ m < 100000) is the number of robot arms. The following m lines indicate the positions of the robot arms by two integers xi (0 < xi < 100000) and yi (1 ≤ yi < n). Here, xi is the x-coordinate of the i-th robot arm, which can pick goods on either the lane yi or the lane yi + 1 at position x = xi , and then release them on the other at the same x-coordinate. You can assume that positions of no two robot arms have the same x-coordinate, that is, xi ≠ xj for any i ≠ j

在这里插入图片描述

Output

Output n integers separated by a space in one line. The i-th integer is the number of the manufacturing lines from which the storage room connected to the conveyor lane i can accept goods.

Sample Input

4 3
1000 1
2000 2
3000 3

Sample Output

2 3 4 4


题目大意:给你m个机器臂(只能上下动)的坐标,x,y,它们在第y+1个传送带上,它们可将自己的物品传给上一个,也可以将上一个传送带的物品拿到下面来。问你每个传送带最终能够有多少种物品。
emmm,注意这一题每个传送带可能有多个机器臂。我们可以发现每个传送带上的物品的编号绝对是连续的,那么该传送带上的最终物品种数就是最大的物品编号-最小的物品编号+1。但是由于机械臂只能上下移动,所以假如机械臂后面增加了物品种数,它并不能将它传上去,所以我们要按照x的位置排序,如果前面增加了,那么我们一定可以将它传上去。so这道题也就over了。。。
以下是详细代码:

#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
struct node 
{
	int pos,line;
	bool friend operator <(node a,node b){
		return a.pos<b.pos;
	}
}a[200050];
int dp[200050][3];
int main()
{
	int n,m;
	scanf ("%d%d",&n,&m);
	for (int i=1; i<=m; i++){
		scanf ("%d%d",&a[i].pos,&a[i].line);
		a[i].line++;
	}
	sort(a+1,a+1+m);
	for (int i=1; i<=n; i++) {
		dp[i][1]=dp[i][0]=i;//初始化每层的最大最小编号为自身
	}
	for (int i=1; i<=m; i++){
		int x=a[i].line;
		dp[x-1][1]=dp[x][1];//将该层的最大编号传给上一层
		dp[x][0]=dp[x-1][0];//将上一层的最小编号传给该层
	}
	for (int i=1; i<n; i++){
		printf ("%d ",dp[i][1]-dp[i][0]+1);
	}
	printf ("%d\n",dp[n][1]-dp[n][0]+1);
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值