BNUOJ33568 Glass Pyramid (DFS)

Source: Internet
Author: User

BNUOJ33568 Glass Pyramid (DFS)
Glass PyramidTime Limit:1000 msMemory Limit:65536KB This problem will be judged on Ural. Original ID: 1968
64-bit integer IO format:% LldJava class name:(Any)Prev Submit Status Statistics Discuss NextFont Size:+-Vova is a skyscraper fan. when he arrives in a city that has any skyscrapers, he always tries to get to the observation deck in the highest skyscraper to make several shots from there. this time is no exception. as soon as Vova arrived in Hong Kong, right after checking in a hotel, he got to the International joint cial Center, a 118-floor building that was built a couple of years ago. before the main entrance into the International trusted cial Center there is a pyramid of large glass blocks. each block has the shape of a one meter height rectangular parallelepiped with a 2 × 2 meter square base. the pyramid's lowest layer isM×NMeter large. The second layer is ( M? 2) × ( N? 2) Meter large and is located so that the vertices of each block's lower side coincided with the centers of the upper sides of the previous layer. the third and the next layers are constructed similarly. the upper layer consists of a single row of blocks (specifically,M=NIt consists of one block ). some pyramid blocks are made of colorless glass and the other blocks are made of reddish glass. when Vova got to the observation platform, located at the skyscraper's 100-th floor, he saw the pyramid from there as a rectangular field, divided into 1 × 1 meter cells. the reddish hue of each cell hinted the number of reddish glass blocks that laid on this cell. vova took the photo of the pyramid from above and now he wants you to take a look at this photo and find out which pyramid blocks are made of reddish glass and which ones are made of colorless glass. vova also says that there is no reddish block lying exactly abve a colorless block. inputThe first line contains integersMAndNThat are sizes of the pyramid's base (2 ≤M,N≤ 40;MAndNAre even). ThenMLines follow, each of them containsNNon-negative integers, describing the photo Vova took. each integer shows the number of reddish blocks lying abve the corresponding cell. it is guaranteed that the input gives some possible arrangement of blocks in the pyramid. outputPrint the description of the layers, from the lowest one to the highest one. to print information aboutI-Th layer, useKILines each containingLICharacters (K1 =M/2;L1 =N/2; K I= K I? 1? 1; L I= L I? 1? 1 ). Character "R" represents a reddish block, "W" represents a colorless block. each next layer is separated from the previous one by an empty line. if there are multiple solutions, you can print any of them. sample Input

Input Output
4 60 0 1 1 0 00 0 1 2 1 00 0 0 1 2 10 0 0 0 1 1
WRWWWRWR
SourceOpen Ural FU Personal Contest 2013
#include
 
  const int N = 50;int mapt[N][N];void print(int sx,int sy){    int mint=1;    for(int i=sx;i
  
   0?"R":"W");}int numb;void dfs(int rs,int re,int hs,int he,int k){    for(int i=rs;i
   
    =numb)        return ;    printf("\n");    dfs(rs+1,re-1,hs+1,he-1,k+1);}int main(){    int n,m;    scanf("%d%d",&n,&m);    {        for(int i=1;i<=n;i++)            for(int j=1;j<=m;j++)            scanf("%d",&mapt[i][j]);        numb=n;        if(numb>m)            numb=m;        numb-=2;        dfs(1,n,1,m,1);    }}
   
  
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.