2019中山大学程序设计竞赛(重现赛) 1008 Clumsy Keke

Clumsy Keke

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1199    Accepted Submission(s): 595


 

Problem Description

Keke is currently studying engineering drawing courses, and the teacher has taught her how to find its volume through the three views of the part. But her brain doesn't work well that she can't find the volume of complex parts. So she needs your help.

To simplify the problem, the part is made up of cubes with side length 1, and the vertices of these cubes are all on the grid. Give you three 0/1 matrices, each representing each of the three views. 0 means that there is no projection of cubes at this position of the view; 1 means that there is a projection of cubes at this position of the view.

Now Keke wants you to help her find the volume of the part determined by the three views.

 

 

Input

There are mutiple test cases, the number of which is no more than 10. For each test case:

The first line of input contains three integers mx,my,mz(1≤mx,my,mz≤99) , which represent the coordinate range of all possible cubes (i.e. all possible cubes are in the cuboid area whose body diagonal is from (1,1,1) to (mx,my,mz)).

Following input a 0/1 matrix with mx lines and my columns representing the front view, and the y-th column of the x-th row represents the projection of all the cubes in the front view such as (x,y,?).

Following input a 0/1 matrix with my lines and mz columns representing the side view, and the z-th column of the y-th row represents the projections of all the cubes in the side view such as (?,y,z).

Following input a 0/1 matrix with mz lines and mx columns representing the top view, and the x-th column of the z-th row represents the projection of all the cubes of the top view such as (x,?,z).

The '?' in the above coordinates represents any integer. Numbers in the same line are separated by spaces. For more detailed input information, please see the sample.

 

 

Output

For each test case:

The first line of output should contain an integer, representing the volume of the part determined by the three views. If the determined part is not unique, find the largest of all possible parts.

Keke's teacher promises that there is at least one part that satisfies the input.

 

 

Sample Input

 

5 6 4 1 1 1 1 1 1 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1

 

 

Sample Output

 

17

Hint

2019中山大学程序设计竞赛(重现赛) 1008 Clumsy Keke_第1张图片

 

题意:

给出一个立体的三视图,求体积。

分析:

数据好像很水,反正我们水过了,队友想的是固定一个平面,然后根据另两个平面判断具体某一个坐标有没有,判断标准是三个必须都是1,具体看代码。

以上还有点思维含量,但是是错误的。

正解是直接暴力枚举,如果为0,则这一条线直接为0,然后累加答案即可

正解暴力

#include
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=20000010;
int a[105][105][105],b,x,y,z,X,Y,Z,ans;
int main(){
    while(scanf("%d%d%d",&X,&Y,&Z)!=EOF){
        for(x=1;x<=X;x++)
        for(y=1;y<=Y;y++)
        for(z=1;z<=Z;z++)a[x][y][z]=1;
        for(x=1;x<=X;x++)for(y=1;y<=Y;y++){
            scanf("%d",&b);
            if(!b)
            	for(z=1;z<=Z;z++)a[x][y][z]=0;
        }
        for(y=1;y<=Y;y++)for(z=1;z<=Z;z++){
            scanf("%d",&b);
            if(!b)for(x=1;x<=X;x++)a[x][y][z]=0;
        }
        for(z=1;z<=Z;z++)
        for(x=1;x<=X;x++){
            scanf("%d",&b);
            if(!b)for(y=1;y<=Y;y++)a[x][y][z]=0;
        }
        ans=0;
        for(x=1;x<=X;x++)
        for(y=1;y<=Y;y++)
        for(z=1;z<=Z;z++)ans+=a[x][y][z];
        printf("%d\n",ans);
    }
    return 0;
}

水过代码

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0};
const int dy[] = {0,0,-1,1};
using namespace std;
int a[105][105];
int b[105][105];
int c[105][105];
int mx,my,mz;
int main() {
    int n;
    while(scanf("%d%d%d",&mx,&my,&mz)!=EOF){
        for(int i=1;i<=mx;i++)
            for(int j=1;j<=my;++j)
                scanf("%d",&a[i][j]);
        for(int i=1;i<=my;i++)
            for(int j=1;j<=mz;++j)
                scanf("%d",&b[i][j]);
        for(int i=1;i<=mz;i++)
            for(int j=1;j<=mx;++j)
                scanf("%d",&c[i][j]);

        int num=0;
        for(int i=1;i<=mx;++i)
        {
            for(int j=1;j<=my;++j)
            {
                if(a[i][j])
                {
                    for(int k=1;k<=mz;k++)
                    {
                        if(b[j][k]  && c[k][i])
                        {
                            num++;
                        }
                    }
                }
            }
        }
        printf("%d\n",num);
    }
    return 0;
}
[ Copy to Clipboard ]    [ Save to File]

 

你可能感兴趣的:(比赛题解,好题)