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 11, and the vertices of these cubes are all on the grid. Give you three 0/1 matrices, each representing each of the three views. 00 means that there is no projection of cubes at this position of the view; 11 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)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)(1,1,1) to (mx,my,mz)(mx,my,mz)).
Following input a 0/1 matrix with mxmx lines and mymy columns representing the front view, and the yy-th column of the xx-th row represents the projection of all the cubes in the front view such as (x,y,?)(x,y,?).
Following input a 0/1 matrix with mymy lines and mzmz columns representing the side view, and the zz-th column of the yy-th row represents the projections of all the cubes in the side view such as (?,y,z)(?,y,z).
Following input a 0/1 matrix with mzmz lines and mxmx columns representing the top view, and the xx-th column of the zz-th row represents the projection of all the cubes of the top view such as (x,?,z)(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
#include <bits/stdc++.h>
using namespace std;
int vs[2400010];
int main()
{
char s[300010];
cin>>s;
int len=strlen(s);
int i,t=0;
for(i=0;i<len;i++)
{
int a=(int)s[i];
while(a)
{
vs[t++]=a%2;
a=a/2;
}
vs[t++]=0;
}
for(i=0;i<t;i+=6)
{
int a=0;
int c=1;
for(int j=i+5;j>=i;j--)
{
a+=vs[j]*c;
c*=2;
}
cout<<a<<" ";
}
return 0;
}