FIG Los perspective Valley P1058

 

A large simulation

Ideas:

First time playing table to find the law

Think carefully about ( violent hand count after) the introduction of such an array:

// width increasing amount 
int DM [ . 4 ] = { 0 , 0 , . 4 , 2 }; // . 1 vertically stack, the stack 2 sideways, the front and rear bundle 3 
 // length increased 
int DN [ . 4 ] = { 0 , 3 , 0 , 2 }; // 1 vertically stack, the stack 2 sideways, the front and rear bundle 3

What does it mean? In an initial case, a cube length is seven characters (two-dimensional map corresponding to the width, that is, Y), high or six characters (two-dimensional map corresponding to the length, that is, x)

As shown, a parameter indicating a two-dimensional map orange, black parameter indicating a three-dimensional cube

 

We use 1 represents bristling pile, 2 sideways pile, pile 3 represents around 

we discover

  • Each cube vertically stack a wide two-dimensional map will not change, but the length will be 6 + 3 on the basis of the
  • Each stack sideways a cube, an increase width of 4 7 on the basis of the two-dimensional map, the same length
  • A cube stack before and after each of the two-dimensional map length and width are increased on the basis of the original 2

 

Since we want to output the final map, it is clear that he must first find the length and width

Width is seeking better, because the width of the stack only with the sideways and longitudinal bundle, and the two methods can be input directly and n and m are obtained. FIG mm wide output is set, then:

  mm=7+(n-1)*dm[3]+(m-1)*dm[2];

And long is not the same, not only with the long pile front and rear, but also with the relevant pile up and down, because I do not ybr gods so strong , so I decided to enumerate.

 

for ( int I = . 1 ; I <= n-; I ++ ) 
    { 
        for ( int J = . 1 ; J <= m; J ++ ) 
        { 
            NN = max (NN, Atlas [I] [J] * DN [ . 1 ] + DN [ . 3 ] * (n-I-+ . 1 ) + . 1 );
             // enumeration of each point of length, maximum value 
        } 
    }

 

So we find the length and width, then consider the process of FIG. Can be used to represent the whole point of a map, I chose the lower left corner, it can (to a certain position of the matrix) introduced the lower left corner of the current location, and then covered enough. Since according to the forward from the left to right order of processing, so the cover will first come later, to deal with the problem of perspective

 

Complete code:

 

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;

inline int read()
{
    int ans=0;
    char last=' ',ch=getchar();
    while(ch<'0'||ch>'9') last=ch,ch=getchar();
    while(ch>='0'&&ch<='9') ans=ans*10+ch-'0',ch=getchar();
    if(last=='-') ans=-ans;
    return ans;
}


int n,m;

char s1[6][8]=
{
    "..+---+",
    "./   /|",
    "+---+ |",
    "|   | +",
     " | | /. " ,
     " + --- + .. " 
}; 
// width increasing amount 
int DM [ . 4 ] = { 0 , 0 , . 4 , 2 }; // . 1 bundle vertically, sideways 2 stack, the stack before and after 3 
 // long amount of increase 
int DN [ . 4 ] = { 0 , 3 , 0 , 2 }; // . 1 vertically stack, the stack 2 sideways, the front and rear bundle 3 

char S [ 1000 ] [ 1000 ]; 

int Atlas [ 51 is ] [ 51 is ];

int mm,nn; 

inline void zhetizhenduliu(int i,int j,int x,int y)
{
    int a,b;
    while(atlas[i][j]--)
    {
        for(a=0;a<6;a++)
        for(b=0;b<7;b++)
            if(s1[6-a-1][b]!='.')
                s[x-a][y+b]=s1[6-a-1][b];
        x-=3;
    }
    
    
}

int main()
{
    //freopen("drawing.in","r",stdin);
    //freopen("drawing.out","w",stdout);
    n=read(),m=read();
    
    for(int i=1;i<=1000;i++)
    {
        for(int j=1;j<=1000;j++)
        {
            s[i][j]='.';
        }
    }
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            atlas[i][j]=read();
        }
    }
    
    if(m==1&&n==1&&atlas[1][1]==1){
        printf("..+---+\n./   /|\n+---+ |\n|   | +\n|   |/.\n+---+..\n");
    }

    mm=7+(n-1)*dm[3]+(m-1)*dm[2]; // determined output width 
    for ( int I = . 1 ; I <= n-; I ++ ) 
    { 
        for ( int J = . 1 ; J <= m; J ++ ) 
        { 
            NN = max (NN, Atlas [I] [ J] * DN [ . 1 ] + DN [ . 3 ] * (n-I-+ . 1 ) + . 1 );
             // enumeration long each point, takes a maximum value 
        } 
    } 
    
    
    
    for ( int I = . 1 ; I <= n-; ++ I ) 
    { 
        for ( int J = . 1 , X, Y; J <= m; J ++ ) 
        {
            x=nn-dn[3]*(n-i);
            y=dm[3]*(n-i)+dm[2]*(j-1)+1;
            zhetizhenduliu(i,j,x,y);
        }
    }
    for(int i=1;i<=nn;i++)
    {
        for(int j=1;j<=mm;j++)
        {
            printf("%c",s[i][j]);
        }
        puts("");
    }
    
}

 

 

 

 

PS: Since I was too betel, and when the examination but think of the practice of writing covered local fried, so then it draws on the solution to a problem (and I'm actually thinking about the same)

Guess you like

Origin www.cnblogs.com/lcezych/p/11134840.html