I: Milling machines (2015 German Collegiate Programming Contest (GCPC 15) + POI 10-T3)

A fab lab is an open, small-scale workshop where you
can create or fabricate almost anything you want mostly
by using computer controlled tools like a laser cutter
or a 3D printer. The FAU fab lab recently got a CNC
milling machine. Using the milling machine you can
cut or remove material with different tools from the
surface of a workpiece. It is controlled via a computer
program.
I sometimes wondered what happens if multiple differ-
ent shaped workpieces are sent through the same milling
program. For simplification assume that we have only
two dimensional workpieces without holes. A milling program consists of multiple steps; each
step describes where the milling machine has to remove material (using different tools) from the
top of the surface.
Input
The first line consists of two integers W and S, where W gives the number of workpieces and
S the number of steps in the milling program (1 ≤ W, S ≤ 104). The next line consists of
two integers X and Y , where X gives the width and Y gives the maximal possible height of
workpieces (1 ≤ X, Y ≤ 100).
Then follow W lines, each describing one workpiece. Each workpiece description consists of X
non-negative integers specifying the surface height in that column.
Then follow S lines, each describing one milling step of the milling progam. Each milling
step description consists of X non-negative integers si (0 ≤ si ≤ Y ) specifying the amount of
surface to cut off in each column (relative to the height of the milling area, i.e. Y , not relative to
the top of the workpiece). See Fig. I.1 for details.
Output
For each workpiece, output one line containing X integers specifying the remaining surface
heights (in the same order as in the input).
Figure I.1: Second workpiece in first sample: initial workpiece followed by milling in each
column – the value in the milling program determines the vertical position of the cutter head.
Sample Input 1 Sample Output 1
2 1
3 4
4 4 4
4 2 3
2 3 0
2 1 4
2 1 3
GCPC 2015 – Problem I: Milling machines 17Sample Input 2 Sample Output 2
1 3
10 100
11 22 33 44 55 66 77 88 99 100
1 100 1 100 1 100 1 100 1 100
58 58 58 58 58 58 58 58 58 58
42 42 42 42 42 42 42 42 66 42
11 0 33 0 42 0 42 0 34 0

题意:给定一些组件和操作次数,将每次操作对应区域削去的高度给出,求最终组件每个区域的高度

思路:实际削去的高度为每次操作的最大值,如果最大高度减去削去高度小于原高度就更新高度,否则高度不变

AC代码

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

const int N=10010;

int h[N][110];
int op[110];
int w,s,x,y;

int main()
{
	scanf("%d%d%d%d",&w,&s,&x,&y);
	for(int i=0;i<w;i++)
		for(int j=0;j<x;j++)
			scanf("%d",&h[i][j]);
	
	for(int i=0;i<s;i++)
		for(int j=0;j<x;j++)
		{
			int a;
			scanf("%d",&a);
			op[j]=max(op[j],a);
		}
	
	for(int i=0;i<w;i++)
	{
		for(int j=0;j<x;j++)
			if(h[i][j]<y-op[j])
				printf("%d ",h[i][j]);
			else
				printf("%d ",y-op[j]);
		puts("");
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Double.Qing

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值