Milling machines

编辑代码

  • 1000ms
  • 262144K

Milling machines

 

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 different 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 Format

The first line consists of two integers WWW and SSS, where WWW gives the number of workpieces and SSS the number of steps in the milling program (1≤W,S≤104)(1 \le W, S \le 10^4)(1≤W,S≤104). The next line consists of two integers XXX and YYY , where XXX gives the width and YYY gives the maximal possible height of workpieces (1≤X,Y≤100)(1 \le X, Y \le 100)(1≤X,Y≤100).

Then follow WWW lines, each describing one workpiece. Each workpiece description consists of XXX non-negative integers specifying the surface height in that column.

Then follow SSS lines, each describing one milling step of the milling progam. Each milling step description consists of XXX non-negative integers si (0≤si≤Y)(0 \le s_i \le Y )(0≤si​≤Y) specifying the amount of surface to cut off in each column (relative to the height of the milling area, i.e. YYY , not relative to the top of the workpiece). See Fig. I.111 for details.

Output Format

For each workpiece, output one line containing XXX integers specifying the remaining surface heights (in the same order as in the input).

 

样例输入1
2 1
3 4
4 4 4
4 2 3
2 3 0
样例输出1
2 1 4
2 1 3
样例输入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
样例输出2
11 0 33 0 42 0 42 0 34 0
题目来源

German Collegiate Programming Contest 2015

题目大意

给不同的工件进行相同的切割,求剩下的形状。显然是求切割的最大值。

AC:

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int MAX = 120;
ll wp[11000][MAX] , maxs[MAX];
ll w, s, x, y;
int main()
{
	memset(wp, 0 , sizeof(wp));
	memset(maxs, 0, sizeof(maxs));
	ll temp;
	scanf("%lld%lld", &w, &s);
	scanf("%lld%lld", &x, &y);
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < x; j++) {
			scanf("%lld", &wp[i][j]);
		}
	}
	for (int i = 0; i < s; i++) {
		for(int j = 0 ; j < x ; j++){
			scanf("%lld", &temp);
			maxs[j] = maxs[j] < temp ? temp : maxs[j];
		}
	}

	for (int j = 0; j < x; j++) {
		maxs[j] = y - maxs[j];
	}

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < x; j++) {
			wp[i][j] = wp[i][j] <= maxs[j] ? wp[i][j] : maxs[j];
		}
	}

	for (int i = 0; i < w; i++) {
		for (int j = 0; j < x; j++) {
            if(j == (x - 1)) printf("%lld", wp[i][j]);
			else  printf("%lld ", wp[i][j]);
		}
        if(i != (w - 1) )
		printf("\n");
	}
	return 0;
}

 

转载于:https://my.oschina.net/u/2945566/blog/1848916

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值