Input
The first line contains three positive space-separated integers ?,?,ℎn,m,h (1≤?,?,ℎ≤1001≤n,m,h≤100) — the length, width and height.
The second line contains ?m non-negative space-separated integers ?1,?2,…,??a1,a2,…,am, where ??ai is the height in the ?i-th column from left to right of the front view (0≤??≤ℎ0≤ai≤h).
The third line contains ?n non-negative space-separated integers ?1,?2,…,??b1,b2,…,bn (0≤??≤ℎ0≤bj≤h), where ??bj is the height in the ?j-th column from left to right of the left view.
Each of the following ?n lines contains ?m numbers, each is 00 or 11, representing the top view, where ?j-th number of ?i-th row is 11 if ℎ?,?>0hi,j>0, and 00 otherwise.
It is guaranteed that there is at least one structure satisfying the input.
input
3 7 3
2 3 0 0 2 0 1
2 1 3
1 0 0 0 1 0 0
0 0 0 0 0 0 1
1 1 0 0 0 0 0
output
1 0 0 0 2 0 0
0 0 0 0 0 0 1
2 3 0 0 0 0 0
input
4 5 5
3 5 2 0 4
4 2 5 4
0 0 0 0 1
1 0 1 0 0
0 1 0 0 0
1 1 1 0 0
output
0 0 0 0 4
1 0 2 0 0
0 5 0 0 0
3 4 1 0 0
Output
Output ?n lines, each of them contains ?m integers, the ?j-th number in the ?i-th line should be equal to the height in the corresponding position of the top view. If there are several objects satisfying the views, output any one of them.
Examples
Note
The graph above illustrates the object in the first example.
The first graph illustrates the object in the example output for the second example, and the second graph shows the three-view drawing of it.
题目大意:给出一个立体图形,高度最高为h,第一行给出n、m、h,第二行给出正视图每一列的高度(共m列),第三行给出左视图每一列的高度(共n列),然后有n*m个数,若其值为0,则意味着该处高度为0;若其值为1,则意味着该处高度不为0。求满足题意的立体图形的每一处的高度。(有多个解输出任意一个即可)
思路一:在输入俯视图时,输出对应位置主视图和侧视图的最小值。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define MAX 0x3f3f3f3f
#define fori(a,b) for(int i=a;i<=b;i++)
#define forj(a,b) for(int j=a;j<=b;j++)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const int M=1e2+10;
int main()
{
int n,m,h,i,j,t;
int a[M]={0},b[M]={0};
cin>>n>>m>>h;
for(i=0;i<m;i++)
cin>>a[i];
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
cin>>t;
if(t==1)
cout<<min(b[i],a[j]);
else
cout<<"0";
if(j==m-1)
cout<<endl;
else
cout<<" ";
}
}
return 0;
}
思路2:将3个视图填满,如果这个3维图形的位置是3就代表该位置有东西。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define MAX 0x3f3f3f3f
#define fori(a,b) for(int i=a;i<=b;i++)
#define forj(a,b) for(int j=a;j<=b;j++)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const int M=1e2+10;
int a[110][110][110]={0};
int n,m,h;
int x[110],y[110],z[110][110];
int main()
{
cin>>n>>m>>h;
for(int i=1;i<=m;i++)
{
cin>>x[i];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
for(int k=1;k<=x[j];k++)
{
a[i][j][k]++;
}
}
}
for(int i=1;i<=n;i++)
{
cin>>y[i];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
for(int k=1;k<=y[i];k++)
{
a[i][j][k]++;
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>z[i][j];
if(z[i][j]==1)
{
for(int k=1;k<=h;k++)
{
a[i][j][k]++;
}
}
}
}
int sum=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
int s=0;
for(int k=1;k<=h;k++)
{
if(a[i][j][k]==3)
{
s++;
}
}
cout<<s<<" ";
}
cout<<endl;
}
}