程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> BNUOJ33568 Glass Pyramid(DFS)

BNUOJ33568 Glass Pyramid(DFS)

編輯:C++入門知識

BNUOJ33568 Glass Pyramid(DFS)


Glass Pyramid

1000ms 65536KB This problem will be judged on Ural. Original ID: 1968
64-bit integer IO format: %lld Java class name: (Any) Prev Submit Status Statistics Discuss Next Font Size:Problem illustration 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 Commercial Center, a 118-floor building that was built a couple of years ago. Before the main entrance into the International Commercial 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 is m × 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, at m = n it 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 above a colorless block.

Input

The first line contains integers m and n that are sizes of the pyramid's base (2 ≤ m, n ≤ 40; m and n are even). Then m lines follow, each of them contains n non-negative integers, describing the photo Vova took. Each integer shows the number of reddish blocks lying above the corresponding cell. It is guaranteed that the input gives some possible arrangement of blocks in the pyramid.

Output

Print the description of the layers, from the lowest one to the highest one. To print information about the i-th layer, use ki lines each containing li characters (k1 = m/2; l1 =n/2; ki = ki ? 1 ? 1; li = li ? 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 6
0 0 1 1 0 0
0 0 1 2 1 0
0 0 0 1 2 1
0 0 0 0 1 1
WRW
WWR

WR

Source

Open 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;i0?"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);
    }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved