欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Milling machines(简单模拟)

程序员文章站 2024-02-27 19:08:33
...

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 WW and SS, where WW gives the number of workpieces and SS the number of steps in the milling program (1 \le W, S \le 10^4)(1≤W,S≤104). The next line consists of two integers XX and YY , where XX gives the width and YY gives the maximal possible height of workpieces (1 \le X, Y \le 100)(1≤X,Y≤100).

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

Then follow SS lines, each describing one milling step of the milling progam. Each milling step description consists of XX non-negative integers si (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. YY, not relative to the top of the workpiece). See Fig. I.11 for details.

Output Format

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

Milling machines(简单模拟)

样例输入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<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int mp[10240][101];
int cl[10240],clx;

int main()
{
   int w,s,x,y;
   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",&mp[i][j]);
   for(int i=0;i<s;i++)
       for(int j=0;j<x;j++)
       {
            scanf("%d",&clx);
            if(clx>cl[j]) cl[j]=clx;
       }
   for(int i=0;i<w;i++)
       for(int j=0;j<x;j++)
           if(y-cl[j]<mp[i][j]) mp[i][j]=y-cl[j];
   for(int i=0;i<w;i++)
   {
       for(int j=0;j<x-1;j++)
          printf("%d ",mp[i][j]);
       printf("%d\n",mp[i][x-1]);
   }
   return 0;
}